0

I am developping the function that request member list from Google Stackdriver API

I am using library fallowing code using gradle.

gradle.build

compile 'com.google.cloud:google-cloud-monitoring:0.42.1-beta'

for example, Getting group list is following code.(JAVA)

GroupServiceClient groupServiceClient = GroupServiceClient.create();

ListGroupsRequest request = ListGroupsRequest.newBuilder()
            .setName("projects/" + projectId)
            .build();

ListGroupsPagedResponse response = groupServiceClient.listGroups(request);

response.iterateAll();

like above code, i can get group list using google monitoring libarary

but, there is no method that get member list in group

is there way to get member list?

1 Answers1

0

You can use example shown in this documentation for Java where it shows how to build the list

Monitoring.Projects.Groups.Members.List request = monitoringService.projects().groups().members().list(name);
ListGroupMembersResponse response;

then

response = request.execute();

and then inside a for loop get the members

MonitoredResource monitoredResource : response.getMembers()
Nakilon
  • 32,203
  • 13
  • 95
  • 132
JMD
  • 552
  • 2
  • 8
  • your code import from [google-api-services-moniroing](https://mvnrepository.com/artifact/com.google.apis/google-api-services-monitoring). But my code import from [google cloud monitoring](https://mvnrepository.com/artifact/com.google.cloud/google-cloud-monitoring) which don't have Members Class. Do you know different that librarys @Nakilon – Shin jaeuk Apr 18 '18 at 07:03
  • You can use a workaround and perform an HTTP request[ 1] for this endpoint: (https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.groups.members/list) You will receive a JSON as a response which you can parse [2]. [1]: https://stackoverflow.com/questions/1359689/how-to-send-http-request-in-java/1359702#1359702 [2]: https://stackoverflow.com/questions/2591098/how-to-parse-json-in-java?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – JMD Apr 23 '18 at 16:07