Search in sources :

Example 81 with OrganizationName

use of com.google.cloud.securitycenter.v1.OrganizationName in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClientTest method createServiceTest2.

@Test
public void createServiceTest2() throws Exception {
    Service expectedResponse = Service.newBuilder().setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()).setDisplayName("displayName1714148973").setTelemetry(Service.Telemetry.newBuilder().build()).putAllUserLabels(new HashMap<String, String>()).build();
    mockServiceMonitoringService.addResponse(expectedResponse);
    OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
    Service service = Service.newBuilder().build();
    Service actualResponse = client.createService(parent, service);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateServiceRequest actualRequest = ((CreateServiceRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(service, actualRequest.getService());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : OrganizationName(com.google.monitoring.v3.OrganizationName) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) CreateServiceRequest(com.google.monitoring.v3.CreateServiceRequest) Service(com.google.monitoring.v3.Service) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) Test(org.junit.Test)

Example 82 with OrganizationName

use of com.google.cloud.securitycenter.v1.OrganizationName in project java-monitoring by googleapis.

the class GroupServiceClientTest method createGroupTest2.

@Test
public void createGroupTest2() throws Exception {
    Group expectedResponse = Group.newBuilder().setName(GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]").toString()).setDisplayName("displayName1714148973").setParentName("parentName-244870571").setFilter("filter-1274492040").setIsCluster(true).build();
    mockGroupService.addResponse(expectedResponse);
    OrganizationName name = OrganizationName.of("[ORGANIZATION]");
    Group group = Group.newBuilder().build();
    Group actualResponse = client.createGroup(name, group);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockGroupService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateGroupRequest actualRequest = ((CreateGroupRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertEquals(group, actualRequest.getGroup());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : OrganizationName(com.google.monitoring.v3.OrganizationName) Group(com.google.monitoring.v3.Group) AbstractMessage(com.google.protobuf.AbstractMessage) CreateGroupRequest(com.google.monitoring.v3.CreateGroupRequest) Test(org.junit.Test)

Example 83 with OrganizationName

use of com.google.cloud.securitycenter.v1.OrganizationName in project java-monitoring by googleapis.

the class GroupServiceClientTest method listGroupsTest2.

@Test
public void listGroupsTest2() throws Exception {
    Group responsesElement = Group.newBuilder().build();
    ListGroupsResponse expectedResponse = ListGroupsResponse.newBuilder().setNextPageToken("").addAllGroup(Arrays.asList(responsesElement)).build();
    mockGroupService.addResponse(expectedResponse);
    OrganizationName name = OrganizationName.of("[ORGANIZATION]");
    ListGroupsPagedResponse pagedListResponse = client.listGroups(name);
    List<Group> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getGroupList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockGroupService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListGroupsRequest actualRequest = ((ListGroupsRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : OrganizationName(com.google.monitoring.v3.OrganizationName) ListGroupsPagedResponse(com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse) ListGroupsRequest(com.google.monitoring.v3.ListGroupsRequest) Group(com.google.monitoring.v3.Group) AbstractMessage(com.google.protobuf.AbstractMessage) ListGroupsResponse(com.google.monitoring.v3.ListGroupsResponse) Test(org.junit.Test)

Example 84 with OrganizationName

use of com.google.cloud.securitycenter.v1.OrganizationName in project gapic-generator-java by googleapis.

the class SyncCreateExclusionOrganizationnameLogexclusion method syncCreateExclusionOrganizationnameLogexclusion.

public static void syncCreateExclusionOrganizationnameLogexclusion() throws Exception {
    // It may require modifications to work in your environment.
    try (ConfigClient configClient = ConfigClient.create()) {
        OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
        LogExclusion exclusion = LogExclusion.newBuilder().build();
        LogExclusion response = configClient.createExclusion(parent, exclusion);
    }
}
Also used : OrganizationName(com.google.logging.v2.OrganizationName) ConfigClient(com.google.cloud.logging.v2.ConfigClient) LogExclusion(com.google.logging.v2.LogExclusion)

Example 85 with OrganizationName

use of com.google.cloud.securitycenter.v1.OrganizationName in project gapic-generator-java by googleapis.

the class SyncCreateSinkOrganizationnameLogsink method syncCreateSinkOrganizationnameLogsink.

public static void syncCreateSinkOrganizationnameLogsink() throws Exception {
    // It may require modifications to work in your environment.
    try (ConfigClient configClient = ConfigClient.create()) {
        OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
        LogSink sink = LogSink.newBuilder().build();
        LogSink response = configClient.createSink(parent, sink);
    }
}
Also used : OrganizationName(com.google.logging.v2.OrganizationName) LogSink(com.google.logging.v2.LogSink) ConfigClient(com.google.cloud.logging.v2.ConfigClient)

Aggregations

Test (org.junit.Test)66 AbstractMessage (com.google.protobuf.AbstractMessage)35 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)31 SecurityCenterClient (com.google.cloud.securitycenter.v1.SecurityCenterClient)31 StatusRuntimeException (io.grpc.StatusRuntimeException)31 OrganizationName (com.google.monitoring.v3.OrganizationName)30 IOException (java.io.IOException)30 OrganizationName (com.google.logging.v2.OrganizationName)22 OrganizationName (com.google.privacy.dlp.v2.OrganizationName)12 ListAssetsRequest (com.google.cloud.securitycenter.v1.ListAssetsRequest)10 ListAssetsResult (com.google.cloud.securitycenter.v1.ListAssetsResponse.ListAssetsResult)10 ListAssetsPagedResponse (com.google.cloud.securitycenter.v1.SecurityCenterClient.ListAssetsPagedResponse)10 GroupResult (com.google.cloud.securitycenter.v1.GroupResult)8 LogExclusion (com.google.logging.v2.LogExclusion)7 LogSink (com.google.logging.v2.LogSink)7 ArrayList (java.util.ArrayList)7 GroupAssetsRequest (com.google.cloud.securitycenter.v1.GroupAssetsRequest)6 GroupAssetsPagedResponse (com.google.cloud.securitycenter.v1.SecurityCenterClient.GroupAssetsPagedResponse)6 MetricDescriptor (com.google.api.MetricDescriptor)3 MockGrpcService (com.google.api.gax.grpc.testing.MockGrpcService)3