// ListMonitoredResourceDescriptors lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account. func (c *MetricClient) ListMonitoredResourceDescriptors(ctx context.Context, req *monitoringpb.ListMonitoredResourceDescriptorsRequest) *MonitoredResourceDescriptorIterator { md, _ := metadata.FromContext(ctx) ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata)) it := &MonitoredResourceDescriptorIterator{} it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoredrespb.MonitoredResourceDescriptor, string, error) { var resp *monitoringpb.ListMonitoredResourceDescriptorsResponse req.PageToken = pageToken if pageSize > math.MaxInt32 { req.PageSize = math.MaxInt32 } else { req.PageSize = int32(pageSize) } err := gax.Invoke(ctx, func(ctx context.Context) error { var err error resp, err = c.metricClient.ListMonitoredResourceDescriptors(ctx, req) return err }, c.CallOptions.ListMonitoredResourceDescriptors...) if err != nil { return nil, "", err } return resp.ResourceDescriptors, resp.NextPageToken, nil } fetch := func(pageSize int, pageToken string) (string, error) { items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) if err != nil { return "", err } it.items = append(it.items, items...) return nextPageToken, nil } it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) return it }
// ListMonitoredResourceDescriptors lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account. func (c *MetricClient) ListMonitoredResourceDescriptors(ctx context.Context, req *monitoringpb.ListMonitoredResourceDescriptorsRequest) *MonitoredResourceDescriptorIterator { ctx = metadata.NewContext(ctx, c.metadata) it := &MonitoredResourceDescriptorIterator{} it.apiCall = func() error { var resp *monitoringpb.ListMonitoredResourceDescriptorsResponse err := gax.Invoke(ctx, func(ctx context.Context) error { var err error req.PageToken = it.nextPageToken req.PageSize = it.pageSize resp, err = c.client.ListMonitoredResourceDescriptors(ctx, req) return err }, c.CallOptions.ListMonitoredResourceDescriptors...) if err != nil { return err } if resp.NextPageToken == "" { it.atLastPage = true } it.nextPageToken = resp.NextPageToken it.items = resp.ResourceDescriptors return nil } return it }