|
| 1 | +/* |
| 2 | + * Copyright 2024 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package vtwo.client; |
| 18 | + |
| 19 | +// [START securitycenter_set_client_endpoint_v2] |
| 20 | + |
| 21 | +import com.google.cloud.securitycenter.v2.SecurityCenterClient; |
| 22 | +import com.google.cloud.securitycenter.v2.SecurityCenterSettings; |
| 23 | +import java.io.IOException; |
| 24 | + |
| 25 | +public class CreateClientWithEndpoint { |
| 26 | + |
| 27 | + public static void main(String[] args) throws IOException { |
| 28 | + // TODO: Replace the value with the endpoint for the region in which your |
| 29 | + // Security Command Center data resides. |
| 30 | + String regionalEndpoint = "securitycenter.me-central2.rep.googleapis.com:443"; |
| 31 | + SecurityCenterClient client = createClientWithEndpoint(regionalEndpoint); |
| 32 | + System.out.println("Client initiated with endpoint: " + client.getSettings().getEndpoint()); |
| 33 | + } |
| 34 | + |
| 35 | + // Creates Security Command Center client for a regional endpoint. |
| 36 | + public static SecurityCenterClient createClientWithEndpoint(String regionalEndpoint) |
| 37 | + throws java.io.IOException { |
| 38 | + SecurityCenterSettings regionalSettings = |
| 39 | + SecurityCenterSettings.newBuilder().setEndpoint(regionalEndpoint).build(); |
| 40 | + return SecurityCenterClient.create(regionalSettings); |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +// [END securitycenter_set_client_endpoint_v2] |
0 commit comments