googleapis / googleapis/google-cloud-go

eventarc/v1: migration help - EventDataContentType missing in cloud.google.com/go/eventarc/apiv1/eventarcpb

Open
#9,071 0 comments 0 reactions 0 assignees View on GitHub
api: eventarc genproto-migration
Dominant language
Go
Stars
4.5k
Forks
1.6k
Avg merge
1d 13h
Merged PRs (30d)
109

Description

I want to create an Eventarc Trigger with the new [cloud.google.com/go/eventarc/apiv1/eventarcpb](https://pkg.go.dev/cloud.google.com/go/eventarc@v1.13.3/apiv1/eventarcpb) library.

**Which client are you migrating**
[google.golang.org/api@v0.152.0/eventarc/v1](https://pkg.go.dev/google.golang.org/api@v0.152.0/eventarc/v1#Trigger)

**What issue are you having**
The new [cloud.google.com/go/eventarc/apiv1/eventarcpb](https://pkg.go.dev/cloud.google.com/go/eventarc@v1.13.3/apiv1/eventarcpb) library is missing support for `EventDataContentType`.

It is present here [google-api-go-client/.../eventarc/v1/eventarc-gen.go#L1947](https://github.com/googleapis/google-api-go-client/blob/main/eventarc/v1/eventarc-gen.go#L1947) but missing in [googleapis/.../eventarc/v1/trigger.proto](https://github.com/googleapis/googleapis/blob/master/google/cloud/eventarc/v1/trigger.proto)

So I'm unable to create an Eventarc trigger:

```go

import (
"context"
"errors"

eventarc "cloud.google.com/go/eventarc/apiv1"
"cloud.google.com/go/eventarc/apiv1/eventarcpb"
)

destination := eventarcpb.Destination{
Descriptor_: &eventarcpb.Destination_CloudRun{
CloudRun: &eventarcpb.CloudRun{
Region: region,
Service: runService,
Path: path,
},
},
}

eventFilterType := eventarcpb.EventFilter{
Attribute: "type",
Value: "google.cloud.firestore.document.v1.created",
}

eventFilterDatabase := eventarcpb.EventFilter{
Attribute: "database",
Value: database,
}

eventFilterDocument := eventarcpb.EventFilter{
Attribute: "document",
Value: "f00bar/*",
Operator: "match-path-pattern",
}

trigger := &eventarcpb.Trigger{
Name: "projects/" + projectId + "/locations/" + region + "/triggers/" + name,
ServiceAccount: serviceAccount,
Destination: &destination,
EventFilters: []*eventarcpb.EventFilter{
&eventFilterType,
&eventFilterDatabase,
&eventFilterDocument,
},
Labels: map[string]string{
"env": label,
},
// EventDataContentType: "application/protobuf",
}

req := &eventarcpb.CreateTriggerRequest{
Parent: "projects/" + projectId + "/locations/" + region,
Trigger: trigger,
TriggerId: name,
}
```

Error message:
```
msg="rpc error: code = InvalidArgument
desc = The request was invalid: invalid value for trigger.event_data_content_type: \"\" is not supported by this event type\n
error details: name = BadRequest field = trigger.event_data_content_type desc = \n
```

**Expected behavior**
I am able to create an Eventarc trigger, which is triggered by Firestore and routes the event to Cloud Run.

**Relevant go.mod dependencies**
```
/ /go.mod
require (
cloud.google.com/go v0.111.0 // indirect
cloud.google.com/go/eventarc v1.13.3 // indirect
[...]
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
)
```

**Additional context**
Workaround is to still use the old library which provides support for `EventDataContentType`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.