Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [securitycenter] Add SimulateSecurityHealthAnalyticsCustomModule API for testing SHA custom module #9980

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions java-securitycenter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.23.0</version>
<version>26.25.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -195,7 +195,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java11.html
[stability-image]: https://img.shields.io/badge/stability-stable-green
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-securitycenter.svg
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-securitycenter/2.32.0
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-securitycenter/2.36.0
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5569,6 +5569,122 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq
return stub.testIamPermissionsCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Simulates a given SecurityHealthAnalyticsCustomModule and Resource.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) {
* String parent = "parent-995424086";
* CustomConfig customConfig = CustomConfig.newBuilder().build();
* SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource resource =
* SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource.newBuilder().build();
* SimulateSecurityHealthAnalyticsCustomModuleResponse response =
* securityCenterClient.simulateSecurityHealthAnalyticsCustomModule(
* parent, customConfig, resource);
* }
* }</pre>
*
* @param parent Required. The relative resource name of the organization, project, or folder.
* See: https://cloud.google.com/apis/design/resource_names#relative_resource_name An example
* is: "organizations/{organization_id}".
* @param customConfig Required. The user specified custom configuration to test.
* @param resource Required. Resource data to simulate custom module against.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final SimulateSecurityHealthAnalyticsCustomModuleResponse
simulateSecurityHealthAnalyticsCustomModule(
String parent,
CustomConfig customConfig,
SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource resource) {
SimulateSecurityHealthAnalyticsCustomModuleRequest request =
SimulateSecurityHealthAnalyticsCustomModuleRequest.newBuilder()
.setParent(parent)
.setCustomConfig(customConfig)
.setResource(resource)
.build();
return simulateSecurityHealthAnalyticsCustomModule(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Simulates a given SecurityHealthAnalyticsCustomModule and Resource.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) {
* SimulateSecurityHealthAnalyticsCustomModuleRequest request =
* SimulateSecurityHealthAnalyticsCustomModuleRequest.newBuilder()
* .setParent("parent-995424086")
* .setCustomConfig(CustomConfig.newBuilder().build())
* .setResource(
* SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource.newBuilder()
* .build())
* .build();
* SimulateSecurityHealthAnalyticsCustomModuleResponse response =
* securityCenterClient.simulateSecurityHealthAnalyticsCustomModule(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final SimulateSecurityHealthAnalyticsCustomModuleResponse
simulateSecurityHealthAnalyticsCustomModule(
SimulateSecurityHealthAnalyticsCustomModuleRequest request) {
return simulateSecurityHealthAnalyticsCustomModuleCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Simulates a given SecurityHealthAnalyticsCustomModule and Resource.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) {
* SimulateSecurityHealthAnalyticsCustomModuleRequest request =
* SimulateSecurityHealthAnalyticsCustomModuleRequest.newBuilder()
* .setParent("parent-995424086")
* .setCustomConfig(CustomConfig.newBuilder().build())
* .setResource(
* SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource.newBuilder()
* .build())
* .build();
* ApiFuture<SimulateSecurityHealthAnalyticsCustomModuleResponse> future =
* securityCenterClient
* .simulateSecurityHealthAnalyticsCustomModuleCallable()
* .futureCall(request);
* // Do something.
* SimulateSecurityHealthAnalyticsCustomModuleResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<
SimulateSecurityHealthAnalyticsCustomModuleRequest,
SimulateSecurityHealthAnalyticsCustomModuleResponse>
simulateSecurityHealthAnalyticsCustomModuleCallable() {
return stub.simulateSecurityHealthAnalyticsCustomModuleCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates external system. This is for a given finding.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,18 @@ public UnaryCallSettings<SetIamPolicyRequest, Policy> setIamPolicySettings() {
return ((SecurityCenterStubSettings) getStubSettings()).testIamPermissionsSettings();
}

/**
* Returns the object with the settings used for calls to
* simulateSecurityHealthAnalyticsCustomModule.
*/
public UnaryCallSettings<
SimulateSecurityHealthAnalyticsCustomModuleRequest,
SimulateSecurityHealthAnalyticsCustomModuleResponse>
simulateSecurityHealthAnalyticsCustomModuleSettings() {
return ((SecurityCenterStubSettings) getStubSettings())
.simulateSecurityHealthAnalyticsCustomModuleSettings();
}

/** Returns the object with the settings used for calls to updateExternalSystem. */
public UnaryCallSettings<UpdateExternalSystemRequest, ExternalSystem>
updateExternalSystemSettings() {
Expand Down Expand Up @@ -796,6 +808,17 @@ public UnaryCallSettings.Builder<SetIamPolicyRequest, Policy> setIamPolicySettin
return getStubSettingsBuilder().testIamPermissionsSettings();
}

/**
* Returns the builder for the settings used for calls to
* simulateSecurityHealthAnalyticsCustomModule.
*/
public UnaryCallSettings.Builder<
SimulateSecurityHealthAnalyticsCustomModuleRequest,
SimulateSecurityHealthAnalyticsCustomModuleResponse>
simulateSecurityHealthAnalyticsCustomModuleSettings() {
return getStubSettingsBuilder().simulateSecurityHealthAnalyticsCustomModuleSettings();
}

/** Returns the builder for the settings used for calls to updateExternalSystem. */
public UnaryCallSettings.Builder<UpdateExternalSystemRequest, ExternalSystem>
updateExternalSystemSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@
"SetMute": {
"methods": ["setMute", "setMute", "setMute", "setMuteCallable"]
},
"SimulateSecurityHealthAnalyticsCustomModule": {
"methods": ["simulateSecurityHealthAnalyticsCustomModule", "simulateSecurityHealthAnalyticsCustomModule", "simulateSecurityHealthAnalyticsCustomModuleCallable"]
},
"TestIamPermissions": {
"methods": ["testIamPermissions", "testIamPermissions", "testIamPermissions", "testIamPermissionsCallable"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
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.SimulateSecurityHealthAnalyticsCustomModuleRequest;
import com.google.cloud.securitycenter.v1.SimulateSecurityHealthAnalyticsCustomModuleResponse;
import com.google.cloud.securitycenter.v1.Source;
import com.google.cloud.securitycenter.v1.UpdateBigQueryExportRequest;
import com.google.cloud.securitycenter.v1.UpdateExternalSystemRequest;
Expand Down Expand Up @@ -498,6 +500,25 @@ public class GrpcSecurityCenterStub extends SecurityCenterStub {
ProtoUtils.marshaller(TestIamPermissionsResponse.getDefaultInstance()))
.build();

private static final MethodDescriptor<
SimulateSecurityHealthAnalyticsCustomModuleRequest,
SimulateSecurityHealthAnalyticsCustomModuleResponse>
simulateSecurityHealthAnalyticsCustomModuleMethodDescriptor =
MethodDescriptor
.<SimulateSecurityHealthAnalyticsCustomModuleRequest,
SimulateSecurityHealthAnalyticsCustomModuleResponse>
newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.cloud.securitycenter.v1.SecurityCenter/SimulateSecurityHealthAnalyticsCustomModule")
.setRequestMarshaller(
ProtoUtils.marshaller(
SimulateSecurityHealthAnalyticsCustomModuleRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(
SimulateSecurityHealthAnalyticsCustomModuleResponse.getDefaultInstance()))
.build();

private static final MethodDescriptor<UpdateExternalSystemRequest, ExternalSystem>
updateExternalSystemMethodDescriptor =
MethodDescriptor.<UpdateExternalSystemRequest, ExternalSystem>newBuilder()
Expand Down Expand Up @@ -718,6 +739,10 @@ public class GrpcSecurityCenterStub extends SecurityCenterStub {
private final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable;
private final UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsCallable;
private final UnaryCallable<
SimulateSecurityHealthAnalyticsCustomModuleRequest,
SimulateSecurityHealthAnalyticsCustomModuleResponse>
simulateSecurityHealthAnalyticsCustomModuleCallable;
private final UnaryCallable<UpdateExternalSystemRequest, ExternalSystem>
updateExternalSystemCallable;
private final UnaryCallable<UpdateFindingRequest, Finding> updateFindingCallable;
Expand Down Expand Up @@ -1152,6 +1177,22 @@ protected GrpcSecurityCenterStub(
return builder.build();
})
.build();
GrpcCallSettings<
SimulateSecurityHealthAnalyticsCustomModuleRequest,
SimulateSecurityHealthAnalyticsCustomModuleResponse>
simulateSecurityHealthAnalyticsCustomModuleTransportSettings =
GrpcCallSettings
.<SimulateSecurityHealthAnalyticsCustomModuleRequest,
SimulateSecurityHealthAnalyticsCustomModuleResponse>
newBuilder()
.setMethodDescriptor(simulateSecurityHealthAnalyticsCustomModuleMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
GrpcCallSettings<UpdateExternalSystemRequest, ExternalSystem>
updateExternalSystemTransportSettings =
GrpcCallSettings.<UpdateExternalSystemRequest, ExternalSystem>newBuilder()
Expand Down Expand Up @@ -1475,6 +1516,11 @@ protected GrpcSecurityCenterStub(
testIamPermissionsTransportSettings,
settings.testIamPermissionsSettings(),
clientContext);
this.simulateSecurityHealthAnalyticsCustomModuleCallable =
callableFactory.createUnaryCallable(
simulateSecurityHealthAnalyticsCustomModuleTransportSettings,
settings.simulateSecurityHealthAnalyticsCustomModuleSettings(),
clientContext);
this.updateExternalSystemCallable =
callableFactory.createUnaryCallable(
updateExternalSystemTransportSettings,
Expand Down Expand Up @@ -1799,6 +1845,14 @@ public UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
return testIamPermissionsCallable;
}

@Override
public UnaryCallable<
SimulateSecurityHealthAnalyticsCustomModuleRequest,
SimulateSecurityHealthAnalyticsCustomModuleResponse>
simulateSecurityHealthAnalyticsCustomModuleCallable() {
return simulateSecurityHealthAnalyticsCustomModuleCallable;
}

@Override
public UnaryCallable<UpdateExternalSystemRequest, ExternalSystem> updateExternalSystemCallable() {
return updateExternalSystemCallable;
Expand Down
Loading