func()

in pkg/plugin/cloudlogging/client.go [203:226]


func (c *Client) ListProjectBucketViews(ctx context.Context, projectId string, bucketId string) ([]string, error) {
	views := []string{""}

	req := &loggingpb.ListViewsRequest{
		// See https://pkg.go.dev/cloud.google.com/go/logging/apiv2/loggingpb#ListViewsRequest
		Parent: fmt.Sprintf("projects/%s/locations/%s", projectId, bucketId),
	}
	it := c.configClient.ListViews(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return nil, err
		}
		// See response format: https://cloud.google.com/logging/docs/reference/v2/rest/v2/billingAccounts.locations.buckets.views#LogView
		view := strings.Split(resp.Name, "/")
		// Append `my-view` for `projects/my-project/locations/global/buckets/my-bucket/views/my-view`
		views = append(views, view[len(view)-1])
	}

	return views, nil
}