Krishna Indani
Krishna Indani

Reputation: 11

How do I list the cloud functions based on user labels?

I see in the ListFunctions calls, it is returning all the functions in the project and specified region. I would like to filter by labels and I don't see the ListFunctionsRequest accept the filter, to filter it by labels. Any suggestions? Something like what gcloud CLI supports: https://cloud.google.com/sdk/gcloud/reference/functions/list

Documentation: https://pkg.go.dev/cloud.google.com/go/functions/apiv1#CloudFunctionsClient.ListFunctions

Code from docs

ctx := context.Background()
    c, err := functions.NewCloudFunctionsClient(ctx)
    if err != nil {
        // TODO: Handle error.
    }
    defer c.Close()

    req := &functionspb.ListFunctionsRequest{
        // TODO: Fill request struct fields.
    }
    it := c.ListFunctions(ctx, req)
    for {
        resp, err := it.Next()
        if err == iterator.Done {
            break
        }
        if err != nil {
            // TODO: Handle error.
        }
        // TODO: Use resp.
        _ = resp
    }```

Upvotes: 1

Views: 301

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75890

The Cloud Functions API doesn't support filter query parameter

The gcloud filtering is performed by the CLI and not by the API. Therefore, if you use the API directly, you need to reimplement this filter feature.

Upvotes: 1

Related Questions