diff --git a/java-securitycenter/google-cloud-securitycenter/pom.xml b/java-securitycenter/google-cloud-securitycenter/pom.xml index 8e08451c8c2a..45ff0a91a829 100644 --- a/java-securitycenter/google-cloud-securitycenter/pom.xml +++ b/java-securitycenter/google-cloud-securitycenter/pom.xml @@ -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/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterClient.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterClient.java index d2f815c19295..ccaa4e0a43a4 100644 --- a/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterClient.java +++ b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; 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; @@ -36,7 +37,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; @@ -110,13 +110,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 { @@ -148,13 +163,17 @@ 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()); } 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() { @@ -169,10 +188,18 @@ 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. + */ + 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 diff --git a/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterSettings.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterSettings.java index ace062fcf9df..380ad1d6d421 100644 --- a/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterSettings.java +++ b/java-securitycenter/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/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/HttpJsonSecurityCenterCallableFactory.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/HttpJsonSecurityCenterCallableFactory.java new file mode 100644 index 000000000000..022ee1219382 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/HttpJsonSecurityCenterStub.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/HttpJsonSecurityCenterStub.java new file mode 100644 index 000000000000..e1cb0e6cb020 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/SecurityCenterStub.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/SecurityCenterStub.java index 52740ed228c4..4207bbc3a47d 100644 --- a/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/SecurityCenterStub.java +++ b/java-securitycenter/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/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/SecurityCenterStubSettings.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/SecurityCenterStubSettings.java index 3d7fb03225ec..ddb4873ae4ef 100644 --- a/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/SecurityCenterStubSettings.java +++ b/java-securitycenter/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; @@ -918,6 +921,11 @@ public SecurityCenterStub createStub() throws IOException { .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())); @@ -950,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)) @@ -969,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); @@ -1369,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/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClient.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClient.java index 1c7404ec4ada..dceb79526a8a 100644 --- a/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClient.java +++ b/java-securitycenter/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 { @@ -149,13 +164,17 @@ 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()); } 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() { @@ -170,10 +189,18 @@ 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. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a source. diff --git a/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterSettings.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterSettings.java index b9fff807b8f2..f9ddee450e8d 100644 --- a/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterSettings.java +++ b/java-securitycenter/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/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/HttpJsonSecurityCenterCallableFactory.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/HttpJsonSecurityCenterCallableFactory.java new file mode 100644 index 000000000000..7a018a9b8470 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/HttpJsonSecurityCenterStub.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/HttpJsonSecurityCenterStub.java new file mode 100644 index 000000000000..2e5ecc29dcab --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/SecurityCenterStub.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/SecurityCenterStub.java index 4947c7f6dcdd..1072f47bbf3a 100644 --- a/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/SecurityCenterStub.java +++ b/java-securitycenter/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/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/SecurityCenterStubSettings.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/SecurityCenterStubSettings.java index 67255e571240..9a679e91ce35 100644 --- a/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/SecurityCenterStubSettings.java +++ b/java-securitycenter/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; @@ -544,6 +547,11 @@ public SecurityCenterStub createStub() throws IOException { .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())); @@ -576,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)) @@ -595,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); @@ -852,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/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClient.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClient.java index 65812b11cfc3..81e2cd189b56 100644 --- a/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClient.java +++ b/java-securitycenter/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 { @@ -150,13 +165,17 @@ 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()); } 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() { @@ -171,10 +190,18 @@ 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. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a source. diff --git a/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterSettings.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterSettings.java index b831cccc74cb..475a1c90e7c8 100644 --- a/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterSettings.java +++ b/java-securitycenter/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/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/HttpJsonSecurityCenterCallableFactory.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/HttpJsonSecurityCenterCallableFactory.java new file mode 100644 index 000000000000..3c34c982070b --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/HttpJsonSecurityCenterStub.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/HttpJsonSecurityCenterStub.java new file mode 100644 index 000000000000..4e376ba4df5a --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/SecurityCenterStub.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/SecurityCenterStub.java index d3a5bcc5f2a4..930803f2bd5f 100644 --- a/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/SecurityCenterStub.java +++ b/java-securitycenter/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/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/SecurityCenterStubSettings.java b/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/SecurityCenterStubSettings.java index 3c814f310f68..f8610c6dab87 100644 --- a/java-securitycenter/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/SecurityCenterStubSettings.java +++ b/java-securitycenter/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; @@ -680,6 +683,11 @@ public SecurityCenterStub createStub() throws IOException { .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())); @@ -712,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)) @@ -731,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); @@ -1028,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/java-securitycenter/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1/SecurityCenterClientHttpJsonTest.java b/java-securitycenter/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1/SecurityCenterClientHttpJsonTest.java new file mode 100644 index 000000000000..3195ac5e1a85 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClientHttpJsonTest.java b/java-securitycenter/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClientHttpJsonTest.java new file mode 100644 index 000000000000..3577b99169e9 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClientHttpJsonTest.java b/java-securitycenter/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClientHttpJsonTest.java new file mode 100644 index 000000000000..dce80265bf8a --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/AsyncBulkMuteFindings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/AsyncBulkMuteFindings.java new file mode 100644 index 000000000000..c6442a81f54b --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/AsyncBulkMuteFindingsLRO.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/AsyncBulkMuteFindingsLRO.java new file mode 100644 index 000000000000..59ec5b8c8abf --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/SyncBulkMuteFindings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/SyncBulkMuteFindings.java new file mode 100644 index 000000000000..2a6f935d90ca --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/SyncBulkMuteFindingsResourcename.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/SyncBulkMuteFindingsResourcename.java new file mode 100644 index 000000000000..c4de3b47714f --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/SyncBulkMuteFindingsString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/SyncBulkMuteFindingsString.java new file mode 100644 index 000000000000..b439aa3249df --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/create/SyncCreateSetCredentialsProvider.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..0303ea32ae81 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..444ebf04418c --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/create/SyncCreateSetEndpoint.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..99623442016d --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/AsyncCreateBigQueryExport.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/AsyncCreateBigQueryExport.java new file mode 100644 index 000000000000..944fae5bcb1d --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExport.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExport.java new file mode 100644 index 000000000000..5a3e85856ca3 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportFoldernameBigqueryexportString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportFoldernameBigqueryexportString.java new file mode 100644 index 000000000000..bc4fae80ada6 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportFoldernameBigqueryexportString.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportOrganizationnameBigqueryexportString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportOrganizationnameBigqueryexportString.java new file mode 100644 index 000000000000..7bcfcc479a73 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportOrganizationnameBigqueryexportString.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportProjectnameBigqueryexportString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportProjectnameBigqueryexportString.java new file mode 100644 index 000000000000..5a90a8e10841 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportProjectnameBigqueryexportString.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportStringBigqueryexportString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportStringBigqueryexportString.java new file mode 100644 index 000000000000..41eeda70c4f8 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportStringBigqueryexportString.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/AsyncCreateFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/AsyncCreateFinding.java new file mode 100644 index 000000000000..fdc81fbc3d7e --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFinding.java new file mode 100644 index 000000000000..1b85f486764e --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.java new file mode 100644 index 000000000000..3ccbcb371644 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.java new file mode 100644 index 000000000000..140966924526 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/AsyncCreateMuteConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/AsyncCreateMuteConfig.java new file mode 100644 index 000000000000..57c32d9fef7c --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfig.java new file mode 100644 index 000000000000..c8711891c663 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigFoldernameMuteconfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigFoldernameMuteconfig.java new file mode 100644 index 000000000000..5bf575cdbfe9 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigFoldernameMuteconfig.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigFoldernameMuteconfigString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigFoldernameMuteconfigString.java new file mode 100644 index 000000000000..42d37045571d --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigFoldernameMuteconfigString.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigOrganizationnameMuteconfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigOrganizationnameMuteconfig.java new file mode 100644 index 000000000000..4ec394be5e92 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigOrganizationnameMuteconfig.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigOrganizationnameMuteconfigString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigOrganizationnameMuteconfigString.java new file mode 100644 index 000000000000..d356cce1ffa8 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigOrganizationnameMuteconfigString.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigProjectnameMuteconfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigProjectnameMuteconfig.java new file mode 100644 index 000000000000..e0b21878fa16 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigProjectnameMuteconfig.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigProjectnameMuteconfigString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigProjectnameMuteconfigString.java new file mode 100644 index 000000000000..a2c630aecbcc --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigProjectnameMuteconfigString.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigStringMuteconfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigStringMuteconfig.java new file mode 100644 index 000000000000..35ef03af3260 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigStringMuteconfigString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigStringMuteconfigString.java new file mode 100644 index 000000000000..108448636987 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigStringMuteconfigString.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/AsyncCreateNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/AsyncCreateNotificationConfig.java new file mode 100644 index 000000000000..e180cb232755 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfig.java new file mode 100644 index 000000000000..c6547af1d61a --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameNotificationconfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameNotificationconfig.java new file mode 100644 index 000000000000..740d4fd74112 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameNotificationconfig.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameStringNotificationconfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameStringNotificationconfig.java new file mode 100644 index 000000000000..0a417a6b1e5a --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameStringNotificationconfig.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringNotificationconfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringNotificationconfig.java new file mode 100644 index 000000000000..b0b7edd96899 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringNotificationconfig.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringStringNotificationconfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringStringNotificationconfig.java new file mode 100644 index 000000000000..e61dd79f5f03 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringStringNotificationconfig.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/AsyncCreateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/AsyncCreateSource.java new file mode 100644 index 000000000000..2e2d2bcf0811 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/SyncCreateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/SyncCreateSource.java new file mode 100644 index 000000000000..2eddbe7030f1 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.java new file mode 100644 index 000000000000..9a9a94d4a932 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/SyncCreateSourceStringSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/SyncCreateSourceStringSource.java new file mode 100644 index 000000000000..f3d5cfd399ce --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/AsyncDeleteBigQueryExport.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/AsyncDeleteBigQueryExport.java new file mode 100644 index 000000000000..865d5cc4e1cc --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExport.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExport.java new file mode 100644 index 000000000000..57d747c2abb6 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExport.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_deletebigqueryexport_sync] +import com.google.cloud.securitycenter.v1.BigQueryExportName; +import com.google.cloud.securitycenter.v1.DeleteBigQueryExportRequest; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExportBigqueryexportname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExportBigqueryexportname.java new file mode 100644 index 000000000000..97db22db836f --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExportBigqueryexportname.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_deletebigqueryexport_bigqueryexportname_sync] +import com.google.cloud.securitycenter.v1.BigQueryExportName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExportString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExportString.java new file mode 100644 index 000000000000..c4d0b3bb26bc --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExportString.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_deletebigqueryexport_string_sync] +import com.google.cloud.securitycenter.v1.BigQueryExportName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/AsyncDeleteMuteConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/AsyncDeleteMuteConfig.java new file mode 100644 index 000000000000..e0448668759b --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfig.java new file mode 100644 index 000000000000..d113ab803126 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfig.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_deletemuteconfig_sync] +import com.google.cloud.securitycenter.v1.DeleteMuteConfigRequest; +import com.google.cloud.securitycenter.v1.MuteConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfigMuteconfigname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfigMuteconfigname.java new file mode 100644 index 000000000000..70f2d84cf370 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfigMuteconfigname.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_deletemuteconfig_muteconfigname_sync] +import com.google.cloud.securitycenter.v1.MuteConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfigString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfigString.java new file mode 100644 index 000000000000..696cc9f15ae2 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfigString.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_deletemuteconfig_string_sync] +import com.google.cloud.securitycenter.v1.MuteConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/AsyncDeleteNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/AsyncDeleteNotificationConfig.java new file mode 100644 index 000000000000..a2569af3dbc7 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfig.java new file mode 100644 index 000000000000..5ae3b4ac1601 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfig.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_deletenotificationconfig_sync] +import com.google.cloud.securitycenter.v1.DeleteNotificationConfigRequest; +import com.google.cloud.securitycenter.v1.NotificationConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigNotificationconfigname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigNotificationconfigname.java new file mode 100644 index 000000000000..68a3ed59c846 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigNotificationconfigname.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_deletenotificationconfig_notificationconfigname_sync] +import com.google.cloud.securitycenter.v1.NotificationConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigString.java new file mode 100644 index 000000000000..5581273354b5 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigString.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_deletenotificationconfig_string_sync] +import com.google.cloud.securitycenter.v1.NotificationConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/AsyncGetBigQueryExport.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/AsyncGetBigQueryExport.java new file mode 100644 index 000000000000..abcc7c333529 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExport.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExport.java new file mode 100644 index 000000000000..d84f188fa5d3 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExportBigqueryexportname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExportBigqueryexportname.java new file mode 100644 index 000000000000..581321663ed9 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExportBigqueryexportname.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExportString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExportString.java new file mode 100644 index 000000000000..6181d573608c --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/AsyncGetIamPolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 000000000000..ab71ffe618a0 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/SyncGetIamPolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 000000000000..b310462863be --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/SyncGetIamPolicyResourcename.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/SyncGetIamPolicyResourcename.java new file mode 100644 index 000000000000..bd01436858fa --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/SyncGetIamPolicyString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/SyncGetIamPolicyString.java new file mode 100644 index 000000000000..3db986cd8f98 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/AsyncGetMuteConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/AsyncGetMuteConfig.java new file mode 100644 index 000000000000..c5ddeda13614 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/SyncGetMuteConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/SyncGetMuteConfig.java new file mode 100644 index 000000000000..9b9292da7024 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/SyncGetMuteConfigMuteconfigname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/SyncGetMuteConfigMuteconfigname.java new file mode 100644 index 000000000000..c14b7e199d9e --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/SyncGetMuteConfigString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/SyncGetMuteConfigString.java new file mode 100644 index 000000000000..cad370c9763f --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/AsyncGetNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/AsyncGetNotificationConfig.java new file mode 100644 index 000000000000..47acef37f26b --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfig.java new file mode 100644 index 000000000000..2bb7672b10f0 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigNotificationconfigname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigNotificationconfigname.java new file mode 100644 index 000000000000..df33988ec340 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigNotificationconfigname.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigString.java new file mode 100644 index 000000000000..9969bd782d3a --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/AsyncGetOrganizationSettings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/AsyncGetOrganizationSettings.java new file mode 100644 index 000000000000..69bb59b2af1b --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettings.java new file mode 100644 index 000000000000..941a0314d487 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.java new file mode 100644 index 000000000000..9c39a29caaef --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.java new file mode 100644 index 000000000000..7c6cde6ad3c6 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/AsyncGetSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/AsyncGetSource.java new file mode 100644 index 000000000000..226f27795a96 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/SyncGetSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/SyncGetSource.java new file mode 100644 index 000000000000..c32bc11c6b1f --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/SyncGetSourceSourcename.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/SyncGetSourceSourcename.java new file mode 100644 index 000000000000..3b9ecdbc11e2 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/SyncGetSourceString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/SyncGetSourceString.java new file mode 100644 index 000000000000..c2e7f94fa087 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupassets/AsyncGroupAssets.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupassets/AsyncGroupAssets.java new file mode 100644 index 000000000000..895702ced452 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupassets/AsyncGroupAssetsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupassets/AsyncGroupAssetsPaged.java new file mode 100644 index 000000000000..e00f13d02943 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupassets/SyncGroupAssets.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupassets/SyncGroupAssets.java new file mode 100644 index 000000000000..3a20531887f3 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/AsyncGroupFindings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/AsyncGroupFindings.java new file mode 100644 index 000000000000..c13adfe19563 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/AsyncGroupFindingsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/AsyncGroupFindingsPaged.java new file mode 100644 index 000000000000..d236895d6b1f --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/SyncGroupFindings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/SyncGroupFindings.java new file mode 100644 index 000000000000..bd0dcd08bd50 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.java new file mode 100644 index 000000000000..8603c1231ed9 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/SyncGroupFindingsStringString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/SyncGroupFindingsStringString.java new file mode 100644 index 000000000000..5eda0bedd82d --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listassets/AsyncListAssets.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listassets/AsyncListAssets.java new file mode 100644 index 000000000000..04cb213bf458 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listassets/AsyncListAssetsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listassets/AsyncListAssetsPaged.java new file mode 100644 index 000000000000..98397f36409a --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listassets/SyncListAssets.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listassets/SyncListAssets.java new file mode 100644 index 000000000000..7b483d008a41 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/AsyncListBigQueryExports.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/AsyncListBigQueryExports.java new file mode 100644 index 000000000000..729a83509ded --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/AsyncListBigQueryExportsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/AsyncListBigQueryExportsPaged.java new file mode 100644 index 000000000000..5e8de8ccbcf8 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExports.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExports.java new file mode 100644 index 000000000000..8ff14d0e03b1 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsFoldername.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsFoldername.java new file mode 100644 index 000000000000..0b460786878a --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsOrganizationname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsOrganizationname.java new file mode 100644 index 000000000000..bde0310839e0 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsOrganizationname.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsProjectname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsProjectname.java new file mode 100644 index 000000000000..ce8c0514f38a --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsString.java new file mode 100644 index 000000000000..ae18f64e76d1 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listfindings/AsyncListFindings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listfindings/AsyncListFindings.java new file mode 100644 index 000000000000..be611932455e --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listfindings/AsyncListFindingsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listfindings/AsyncListFindingsPaged.java new file mode 100644 index 000000000000..e6bd21b897e0 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listfindings/SyncListFindings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listfindings/SyncListFindings.java new file mode 100644 index 000000000000..e715c470d577 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/AsyncListMuteConfigs.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/AsyncListMuteConfigs.java new file mode 100644 index 000000000000..aacc5b034c6c --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/AsyncListMuteConfigsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/AsyncListMuteConfigsPaged.java new file mode 100644 index 000000000000..0fe17ccbcddc --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigs.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigs.java new file mode 100644 index 000000000000..c4a7f38a80d2 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsFoldername.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsFoldername.java new file mode 100644 index 000000000000..e2dcb46d200f --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsOrganizationname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsOrganizationname.java new file mode 100644 index 000000000000..d1c9e4adece2 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsProjectname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsProjectname.java new file mode 100644 index 000000000000..eaa075bf53cc --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsString.java new file mode 100644 index 000000000000..6ead853dd7dc --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigs.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigs.java new file mode 100644 index 000000000000..8b89ce519386 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigsPaged.java new file mode 100644 index 000000000000..7edab2ebf51e --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigs.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigs.java new file mode 100644 index 000000000000..18009cc65ccf --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsOrganizationname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsOrganizationname.java new file mode 100644 index 000000000000..cf43901f3609 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsOrganizationname.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsString.java new file mode 100644 index 000000000000..1a5ff84cc56c --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/AsyncListSources.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/AsyncListSources.java new file mode 100644 index 000000000000..7e852d5a592c --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/AsyncListSourcesPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/AsyncListSourcesPaged.java new file mode 100644 index 000000000000..6af7f38e29da --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSources.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSources.java new file mode 100644 index 000000000000..354c82f927b4 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesFoldername.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesFoldername.java new file mode 100644 index 000000000000..44087573a674 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesOrganizationname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesOrganizationname.java new file mode 100644 index 000000000000..2ae71e950ad2 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesProjectname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesProjectname.java new file mode 100644 index 000000000000..1d4bbc0bfccb --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesString.java new file mode 100644 index 000000000000..8b48eaa0e193 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscovery.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscovery.java new file mode 100644 index 000000000000..a0dc92c9fc26 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscoveryLRO.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscoveryLRO.java new file mode 100644 index 000000000000..6e296b223cea --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.java new file mode 100644 index 000000000000..9ee05cbe46a4 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.java new file mode 100644 index 000000000000..a63bae64279d --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.java new file mode 100644 index 000000000000..dbc42e284ab4 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/AsyncSetFindingState.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/AsyncSetFindingState.java new file mode 100644 index 000000000000..8651049b8e1c --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingState.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingState.java new file mode 100644 index 000000000000..6079e61e845a --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.java new file mode 100644 index 000000000000..f2ec41b06d6f --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.java new file mode 100644 index 000000000000..0806a5847f73 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/AsyncSetIamPolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 000000000000..61af4e960a2e --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/SyncSetIamPolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 000000000000..1ea1f69e7f9d --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java new file mode 100644 index 000000000000..52e226016d48 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/SyncSetIamPolicyStringPolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/SyncSetIamPolicyStringPolicy.java new file mode 100644 index 000000000000..8f22b1998dd7 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/AsyncSetMute.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/AsyncSetMute.java new file mode 100644 index 000000000000..a256f9716b08 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/SyncSetMute.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/SyncSetMute.java new file mode 100644 index 000000000000..dc5a6e11630c --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/SyncSetMuteFindingnameFindingmute.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/SyncSetMuteFindingnameFindingmute.java new file mode 100644 index 000000000000..1ddedd5c3e2d --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/SyncSetMuteStringFindingmute.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/SyncSetMuteStringFindingmute.java new file mode 100644 index 000000000000..ec05363660c9 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/AsyncTestIamPermissions.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 000000000000..876842dac6e5 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissions.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 000000000000..503f5defab90 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java new file mode 100644 index 000000000000..6a17a31cf305 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.java new file mode 100644 index 000000000000..501f4b5b7493 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/AsyncUpdateBigQueryExport.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/AsyncUpdateBigQueryExport.java new file mode 100644 index 000000000000..a83c7bee8f10 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/SyncUpdateBigQueryExport.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/SyncUpdateBigQueryExport.java new file mode 100644 index 000000000000..5fc0c7c31461 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/SyncUpdateBigQueryExportBigqueryexportFieldmask.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/SyncUpdateBigQueryExportBigqueryexportFieldmask.java new file mode 100644 index 000000000000..76a9a6a3c208 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/SyncUpdateBigQueryExportBigqueryexportFieldmask.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/AsyncUpdateExternalSystem.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/AsyncUpdateExternalSystem.java new file mode 100644 index 000000000000..1106adfe1a70 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/SyncUpdateExternalSystem.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/SyncUpdateExternalSystem.java new file mode 100644 index 000000000000..174f667e7267 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/SyncUpdateExternalSystemExternalsystemFieldmask.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/SyncUpdateExternalSystemExternalsystemFieldmask.java new file mode 100644 index 000000000000..fadff9485809 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/SyncUpdateExternalSystemExternalsystemFieldmask.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatefinding/AsyncUpdateFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatefinding/AsyncUpdateFinding.java new file mode 100644 index 000000000000..613572319ec6 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatefinding/SyncUpdateFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatefinding/SyncUpdateFinding.java new file mode 100644 index 000000000000..b0c7f133c4cc --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatefinding/SyncUpdateFindingFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatefinding/SyncUpdateFindingFinding.java new file mode 100644 index 000000000000..81831009a2b3 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/AsyncUpdateMuteConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/AsyncUpdateMuteConfig.java new file mode 100644 index 000000000000..dfca37599e25 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/SyncUpdateMuteConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/SyncUpdateMuteConfig.java new file mode 100644 index 000000000000..a4af570e45e3 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/SyncUpdateMuteConfigMuteconfigFieldmask.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/SyncUpdateMuteConfigMuteconfigFieldmask.java new file mode 100644 index 000000000000..5785cba34e6e --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/SyncUpdateMuteConfigMuteconfigFieldmask.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/AsyncUpdateNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/AsyncUpdateNotificationConfig.java new file mode 100644 index 000000000000..988888ec113e --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfig.java new file mode 100644 index 000000000000..527c4b06878c --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfig.java new file mode 100644 index 000000000000..0cb2aaf391f7 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfig.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfigFieldmask.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfigFieldmask.java new file mode 100644 index 000000000000..973bd8c416a1 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfigFieldmask.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/AsyncUpdateOrganizationSettings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/AsyncUpdateOrganizationSettings.java new file mode 100644 index 000000000000..80cb585f060e --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettings.java new file mode 100644 index 000000000000..7004bb78327c --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.java new file mode 100644 index 000000000000..33aa01e17e76 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesecuritymarks/AsyncUpdateSecurityMarks.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesecuritymarks/AsyncUpdateSecurityMarks.java new file mode 100644 index 000000000000..2283acd7943d --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarks.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarks.java new file mode 100644 index 000000000000..2ff9cd0417fe --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.java new file mode 100644 index 000000000000..5db60660e4e9 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesource/AsyncUpdateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesource/AsyncUpdateSource.java new file mode 100644 index 000000000000..2c2bf2e9f70b --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesource/SyncUpdateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesource/SyncUpdateSource.java new file mode 100644 index 000000000000..d38c0e678528 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesource/SyncUpdateSourceSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesource/SyncUpdateSourceSource.java new file mode 100644 index 000000000000..95a923ad7ba0 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycentersettings/createsource/SyncCreateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycentersettings/createsource/SyncCreateSource.java new file mode 100644 index 000000000000..2f743d249ff2 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/stub/securitycenterstubsettings/createsource/SyncCreateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1/stub/securitycenterstubsettings/createsource/SyncCreateSource.java new file mode 100644 index 000000000000..52d7f414c7f6 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..fad6f8db298d --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..89f1d8669889 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/create/SyncCreateSetEndpoint.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..44720964de66 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/AsyncCreateFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/AsyncCreateFinding.java new file mode 100644 index 000000000000..bd107b490126 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFinding.java new file mode 100644 index 000000000000..6b8a4227bc90 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.java new file mode 100644 index 000000000000..5dd4573d603a --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.java new file mode 100644 index 000000000000..e6f1aa3f3788 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/AsyncCreateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/AsyncCreateSource.java new file mode 100644 index 000000000000..1b3229e95576 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSource.java new file mode 100644 index 000000000000..fae418991a7f --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.java new file mode 100644 index 000000000000..c03d770bed9e --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSourceStringSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSourceStringSource.java new file mode 100644 index 000000000000..23dc8c491961 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/AsyncGetIamPolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 000000000000..6f33f808a425 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 000000000000..7151eb372bcd --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyResourcename.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyResourcename.java new file mode 100644 index 000000000000..ad52ceed94a8 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyString.java new file mode 100644 index 000000000000..e6949873d743 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/AsyncGetOrganizationSettings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/AsyncGetOrganizationSettings.java new file mode 100644 index 000000000000..ee4e41d850e0 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettings.java new file mode 100644 index 000000000000..6a75281bb48b --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.java new file mode 100644 index 000000000000..3a9f4b424b97 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.java new file mode 100644 index 000000000000..91ad522880a6 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/AsyncGetSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/AsyncGetSource.java new file mode 100644 index 000000000000..d39af64f0d03 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/SyncGetSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/SyncGetSource.java new file mode 100644 index 000000000000..6d57e51f6af5 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/SyncGetSourceSourcename.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/SyncGetSourceSourcename.java new file mode 100644 index 000000000000..815d8e5536d0 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/SyncGetSourceString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/SyncGetSourceString.java new file mode 100644 index 000000000000..7f6a383e0699 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupassets/AsyncGroupAssets.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupassets/AsyncGroupAssets.java new file mode 100644 index 000000000000..6313d3866a1a --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupassets/AsyncGroupAssetsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupassets/AsyncGroupAssetsPaged.java new file mode 100644 index 000000000000..57cb758beaa9 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupassets/SyncGroupAssets.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupassets/SyncGroupAssets.java new file mode 100644 index 000000000000..08bc766f26ee --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/AsyncGroupFindings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/AsyncGroupFindings.java new file mode 100644 index 000000000000..8646cd7dd01a --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/AsyncGroupFindingsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/AsyncGroupFindingsPaged.java new file mode 100644 index 000000000000..deedcbc9e487 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/SyncGroupFindings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/SyncGroupFindings.java new file mode 100644 index 000000000000..16dbb8c4583a --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.java new file mode 100644 index 000000000000..4d3b46116c6c --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/SyncGroupFindingsStringString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/SyncGroupFindingsStringString.java new file mode 100644 index 000000000000..23a8d703d0c1 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listassets/AsyncListAssets.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listassets/AsyncListAssets.java new file mode 100644 index 000000000000..4d18047e47dc --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listassets/AsyncListAssetsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listassets/AsyncListAssetsPaged.java new file mode 100644 index 000000000000..377a46f1b90f --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listassets/SyncListAssets.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listassets/SyncListAssets.java new file mode 100644 index 000000000000..c7ac274b720e --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listfindings/AsyncListFindings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listfindings/AsyncListFindings.java new file mode 100644 index 000000000000..5b3811773b37 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listfindings/AsyncListFindingsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listfindings/AsyncListFindingsPaged.java new file mode 100644 index 000000000000..f83e131a6bce --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listfindings/SyncListFindings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listfindings/SyncListFindings.java new file mode 100644 index 000000000000..01f5cf15664b --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/AsyncListSources.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/AsyncListSources.java new file mode 100644 index 000000000000..df3cfd5685e9 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/AsyncListSourcesPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/AsyncListSourcesPaged.java new file mode 100644 index 000000000000..9a5a85e63eda --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/SyncListSources.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/SyncListSources.java new file mode 100644 index 000000000000..199a94c39b30 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/SyncListSourcesOrganizationname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/SyncListSourcesOrganizationname.java new file mode 100644 index 000000000000..a4556b72c926 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/SyncListSourcesString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/SyncListSourcesString.java new file mode 100644 index 000000000000..21b53ccd7103 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscovery.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscovery.java new file mode 100644 index 000000000000..588a9573f556 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscoveryLRO.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscoveryLRO.java new file mode 100644 index 000000000000..c788fe3c4bcb --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.java new file mode 100644 index 000000000000..94a1e5eacc03 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.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_runassetdiscovery_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.RunAssetDiscoveryRequest; +import com.google.cloud.securitycenter.v1beta1.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(); + securityCenterClient.runAssetDiscoveryAsync(request).get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_runassetdiscovery_sync] diff --git a/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.java new file mode 100644 index 000000000000..c901b7d3ed9f --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/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.v1beta1.samples; + +// [START +// securitycenter_v1beta1_generated_securitycenterclient_runassetdiscovery_organizationname_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.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]"); + securityCenterClient.runAssetDiscoveryAsync(parent).get(); + } + } +} +// [END +// securitycenter_v1beta1_generated_securitycenterclient_runassetdiscovery_organizationname_sync] diff --git a/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.java new file mode 100644 index 000000000000..ac3237946e16 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.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_runassetdiscovery_string_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.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(); + securityCenterClient.runAssetDiscoveryAsync(parent).get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_runassetdiscovery_string_sync] diff --git a/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/AsyncSetFindingState.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/AsyncSetFindingState.java new file mode 100644 index 000000000000..9447b8345474 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingState.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingState.java new file mode 100644 index 000000000000..c3e710d1c61e --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.java new file mode 100644 index 000000000000..d0263de8607c --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.java new file mode 100644 index 000000000000..0f8a9edca56b --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/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.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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/AsyncSetIamPolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 000000000000..5ac3cea3f6a4 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 000000000000..66e240abe022 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java new file mode 100644 index 000000000000..4de4391ba7c7 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyStringPolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyStringPolicy.java new file mode 100644 index 000000000000..65586d8773e3 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/AsyncTestIamPermissions.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 000000000000..a8b19f01b480 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissions.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 000000000000..08e674d9cb65 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java new file mode 100644 index 000000000000..c70ce141fb14 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.java new file mode 100644 index 000000000000..a1acd91ac598 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatefinding/AsyncUpdateFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatefinding/AsyncUpdateFinding.java new file mode 100644 index 000000000000..238434985086 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatefinding/SyncUpdateFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatefinding/SyncUpdateFinding.java new file mode 100644 index 000000000000..7c311d9e1dbc --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFinding.java new file mode 100644 index 000000000000..da674e83380d --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/AsyncUpdateOrganizationSettings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/AsyncUpdateOrganizationSettings.java new file mode 100644 index 000000000000..89a350a5c4d6 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettings.java new file mode 100644 index 000000000000..ca9e61374d8c --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.java new file mode 100644 index 000000000000..ff15726c8ce0 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/AsyncUpdateSecurityMarks.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/AsyncUpdateSecurityMarks.java new file mode 100644 index 000000000000..bb1bf78d0d44 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarks.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarks.java new file mode 100644 index 000000000000..b2b1fb54d908 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.java new file mode 100644 index 000000000000..99ebabb966c7 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesource/AsyncUpdateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesource/AsyncUpdateSource.java new file mode 100644 index 000000000000..784c7c0fed8c --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesource/SyncUpdateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesource/SyncUpdateSource.java new file mode 100644 index 000000000000..68bb2792048b --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesource/SyncUpdateSourceSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesource/SyncUpdateSourceSource.java new file mode 100644 index 000000000000..e5d3144cc3c5 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycentersettings/createsource/SyncCreateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycentersettings/createsource/SyncCreateSource.java new file mode 100644 index 000000000000..9a86b663302e --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/stub/securitycenterstubsettings/createsource/SyncCreateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/stub/securitycenterstubsettings/createsource/SyncCreateSource.java new file mode 100644 index 000000000000..cde1aaa101e5 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..13dfcbbc9e30 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..e93445c8f5ea --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetEndpoint.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..0e9faceab5c1 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/AsyncCreateFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/AsyncCreateFinding.java new file mode 100644 index 000000000000..155e97ec0de1 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFinding.java new file mode 100644 index 000000000000..cc47ac560211 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameFindingString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameFindingString.java new file mode 100644 index 000000000000..49de1ef5132e --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameFindingString.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.java new file mode 100644 index 000000000000..60c465bda4b7 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingStringFindingString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingStringFindingString.java new file mode 100644 index 000000000000..5fea789c5156 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingStringFindingString.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.java new file mode 100644 index 000000000000..5b0514bf1176 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/AsyncCreateNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/AsyncCreateNotificationConfig.java new file mode 100644 index 000000000000..0126f3dd7f40 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfig.java new file mode 100644 index 000000000000..62a039bfbf0c --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameNotificationconfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameNotificationconfig.java new file mode 100644 index 000000000000..0eb79abbc6c5 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameNotificationconfig.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameStringNotificationconfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameStringNotificationconfig.java new file mode 100644 index 000000000000..9ef72a00d2bb --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameStringNotificationconfig.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringNotificationconfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringNotificationconfig.java new file mode 100644 index 000000000000..a69459f6d8d7 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringNotificationconfig.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringStringNotificationconfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringStringNotificationconfig.java new file mode 100644 index 000000000000..ae8b4d06f978 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringStringNotificationconfig.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/AsyncCreateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/AsyncCreateSource.java new file mode 100644 index 000000000000..d5adb99b5e30 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSource.java new file mode 100644 index 000000000000..30f4a1fe5ec0 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.java new file mode 100644 index 000000000000..9e84f86611ee --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSourceStringSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSourceStringSource.java new file mode 100644 index 000000000000..c8e89a94529a --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/AsyncDeleteNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/AsyncDeleteNotificationConfig.java new file mode 100644 index 000000000000..08dbb80960a3 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfig.java new file mode 100644 index 000000000000..21b21b1c2037 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfig.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_deletenotificationconfig_sync] +import com.google.cloud.securitycenter.v1p1beta1.DeleteNotificationConfigRequest; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfigName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigNotificationconfigname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigNotificationconfigname.java new file mode 100644 index 000000000000..bfb22fe89d4f --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigNotificationconfigname.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_deletenotificationconfig_notificationconfigname_sync] +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfigName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigString.java new file mode 100644 index 000000000000..6c02d1b04a01 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigString.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_string_sync] +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfigName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/AsyncGetIamPolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 000000000000..657b8158ea4a --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 000000000000..6f6d9480a0c5 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyResourcename.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyResourcename.java new file mode 100644 index 000000000000..d4feef0da127 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyString.java new file mode 100644 index 000000000000..6a08effa9af0 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/AsyncGetNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/AsyncGetNotificationConfig.java new file mode 100644 index 000000000000..66248040a286 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfig.java new file mode 100644 index 000000000000..d2fef798bba1 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigNotificationconfigname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigNotificationconfigname.java new file mode 100644 index 000000000000..3bd18a811aca --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigNotificationconfigname.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigString.java new file mode 100644 index 000000000000..e2a8deabcd8f --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/AsyncGetOrganizationSettings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/AsyncGetOrganizationSettings.java new file mode 100644 index 000000000000..ced3e3a23f3e --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettings.java new file mode 100644 index 000000000000..bd9df50fc9fe --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.java new file mode 100644 index 000000000000..b415431dc502 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.java new file mode 100644 index 000000000000..7d586d17dca2 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/AsyncGetSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/AsyncGetSource.java new file mode 100644 index 000000000000..caf50489d99d --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/SyncGetSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/SyncGetSource.java new file mode 100644 index 000000000000..a60c517d0ebd --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/SyncGetSourceSourcename.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/SyncGetSourceSourcename.java new file mode 100644 index 000000000000..9312e47f7fa1 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/SyncGetSourceString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/SyncGetSourceString.java new file mode 100644 index 000000000000..b506eaab7349 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupassets/AsyncGroupAssets.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupassets/AsyncGroupAssets.java new file mode 100644 index 000000000000..2e2d74265c9e --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupassets/AsyncGroupAssetsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupassets/AsyncGroupAssetsPaged.java new file mode 100644 index 000000000000..1cc7768e9de3 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupassets/SyncGroupAssets.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupassets/SyncGroupAssets.java new file mode 100644 index 000000000000..5b4e242c53c5 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/AsyncGroupFindings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/AsyncGroupFindings.java new file mode 100644 index 000000000000..4b4e88efd866 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/AsyncGroupFindingsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/AsyncGroupFindingsPaged.java new file mode 100644 index 000000000000..d1c602f5cc84 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindings.java new file mode 100644 index 000000000000..1b8942f30424 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.java new file mode 100644 index 000000000000..e8b75597f1f9 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindingsStringString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindingsStringString.java new file mode 100644 index 000000000000..6571341b24df --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/AsyncListAssets.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/AsyncListAssets.java new file mode 100644 index 000000000000..f7853ddb1f6c --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/AsyncListAssetsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/AsyncListAssetsPaged.java new file mode 100644 index 000000000000..7900d6e59364 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssets.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssets.java new file mode 100644 index 000000000000..3e01f528d262 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsFoldername.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsFoldername.java new file mode 100644 index 000000000000..93fa81c04d5e --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsOrganizationname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsOrganizationname.java new file mode 100644 index 000000000000..126f01b2aeaa --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsProjectname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsProjectname.java new file mode 100644 index 000000000000..0933c3e5cd94 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsString.java new file mode 100644 index 000000000000..1a0394669287 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/AsyncListFindings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/AsyncListFindings.java new file mode 100644 index 000000000000..8bfe7503b941 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/AsyncListFindingsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/AsyncListFindingsPaged.java new file mode 100644 index 000000000000..bc61ecd98116 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/SyncListFindings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/SyncListFindings.java new file mode 100644 index 000000000000..189954bb9e39 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/SyncListFindingsSourcename.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/SyncListFindingsSourcename.java new file mode 100644 index 000000000000..16a33f01547d --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/SyncListFindingsString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/SyncListFindingsString.java new file mode 100644 index 000000000000..b34b26366ab8 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigs.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigs.java new file mode 100644 index 000000000000..c26244fe1866 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigsPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigsPaged.java new file mode 100644 index 000000000000..8e6b57ffbb70 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigsPaged.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigs.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigs.java new file mode 100644 index 000000000000..3bc416451fd1 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsOrganizationname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsOrganizationname.java new file mode 100644 index 000000000000..04692a04950b --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsOrganizationname.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsString.java new file mode 100644 index 000000000000..21ddff0ae5f2 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsString.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/AsyncListSources.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/AsyncListSources.java new file mode 100644 index 000000000000..c0ff8d2052b5 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/AsyncListSourcesPaged.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/AsyncListSourcesPaged.java new file mode 100644 index 000000000000..8f4900ae6b9b --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSources.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSources.java new file mode 100644 index 000000000000..716ca95ae621 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesFoldername.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesFoldername.java new file mode 100644 index 000000000000..52799cf99790 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesOrganizationname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesOrganizationname.java new file mode 100644 index 000000000000..22d44b9d38b3 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesProjectname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesProjectname.java new file mode 100644 index 000000000000..6ae2cadc8732 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesString.java new file mode 100644 index 000000000000..cfa3be8b373f --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscovery.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscovery.java new file mode 100644 index 000000000000..ad3a6b27e9a8 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscoveryLRO.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscoveryLRO.java new file mode 100644 index 000000000000..60c8c3944942 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.java new file mode 100644 index 000000000000..6cf20f904890 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.java new file mode 100644 index 000000000000..e2ec9e5426bf --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.java new file mode 100644 index 000000000000..9793e94d592f --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/AsyncSetFindingState.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/AsyncSetFindingState.java new file mode 100644 index 000000000000..ff29de42cc44 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingState.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingState.java new file mode 100644 index 000000000000..9bb761c2f563 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.java new file mode 100644 index 000000000000..ad916001a746 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.java new file mode 100644 index 000000000000..bce09b4cfc84 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/AsyncSetIamPolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 000000000000..7d6ee8d41836 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 000000000000..e52356bbf4eb --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java new file mode 100644 index 000000000000..efbedcb47e33 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyStringPolicy.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyStringPolicy.java new file mode 100644 index 000000000000..ca0336f1db17 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/AsyncTestIamPermissions.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 000000000000..66eef964800a --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissions.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 000000000000..6588b315d113 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java new file mode 100644 index 000000000000..6890b1b0a890 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.java new file mode 100644 index 000000000000..f963b1909bc3 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/AsyncUpdateFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/AsyncUpdateFinding.java new file mode 100644 index 000000000000..cad8a131203e --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFinding.java new file mode 100644 index 000000000000..aa3b273f3e65 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFinding.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFinding.java new file mode 100644 index 000000000000..c0c59d54bbee --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFindingFieldmask.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFindingFieldmask.java new file mode 100644 index 000000000000..7361202970b5 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFindingFieldmask.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/AsyncUpdateNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/AsyncUpdateNotificationConfig.java new file mode 100644 index 000000000000..b4aec5ca2ece --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfig.java new file mode 100644 index 000000000000..ee5ff4e8e5ee --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfig.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfig.java new file mode 100644 index 000000000000..ca0ae3de7347 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfig.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfigFieldmask.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfigFieldmask.java new file mode 100644 index 000000000000..e6349b9c7e09 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfigFieldmask.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/AsyncUpdateOrganizationSettings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/AsyncUpdateOrganizationSettings.java new file mode 100644 index 000000000000..8d735bf7f4dd --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettings.java new file mode 100644 index 000000000000..2d866ccab460 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.java new file mode 100644 index 000000000000..a396ceb874ec --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/AsyncUpdateSecurityMarks.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/AsyncUpdateSecurityMarks.java new file mode 100644 index 000000000000..571a072719c5 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarks.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarks.java new file mode 100644 index 000000000000..dda031b9a49b --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.java new file mode 100644 index 000000000000..f030c83f44d7 --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarksFieldmask.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarksFieldmask.java new file mode 100644 index 000000000000..1e3e62e71d1a --- /dev/null +++ b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarksFieldmask.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_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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/AsyncUpdateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/AsyncUpdateSource.java new file mode 100644 index 000000000000..ce7d450ae33b --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/SyncUpdateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/SyncUpdateSource.java new file mode 100644 index 000000000000..ab56c23d88fa --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/SyncUpdateSourceSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/SyncUpdateSourceSource.java new file mode 100644 index 000000000000..000c19b3bcd3 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/SyncUpdateSourceSourceFieldmask.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/SyncUpdateSourceSourceFieldmask.java new file mode 100644 index 000000000000..83521b0262b8 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycentersettings/createsource/SyncCreateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycentersettings/createsource/SyncCreateSource.java new file mode 100644 index 000000000000..f2f56e394fe2 --- /dev/null +++ b/java-securitycenter/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/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/stub/securitycenterstubsettings/createsource/SyncCreateSource.java b/java-securitycenter/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/stub/securitycenterstubsettings/createsource/SyncCreateSource.java new file mode 100644 index 000000000000..7d988d9cb114 --- /dev/null +++ b/java-securitycenter/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]