Lists Eventarc triggers in a specified Google Cloud project and location.

## Code sample

### Go


To authenticate to Eventarc, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```go

import (
	"context"
	"errors"
	"fmt"
	"io"

	eventarc "cloud.google.com/go/eventarc/apiv1"
	eventarcpb "cloud.google.com/go/eventarc/apiv1/eventarcpb"
	"google.golang.org/api/iterator"
)

// listTriggers lists Eventarc triggers in a given project and location.
func listTriggers(ctx context.Context, w io.Writer, projectID string, locationID string) error {
	parent := fmt.Sprintf("projects/%s/locations/%s", projectID, locationID)

	client, err := eventarc.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("eventarc.NewClient: %w", err)
	}
	defer client.Close()

	req := &eventarcpb.ListTriggersRequest{
		Parent: parent,
	}

	it := client.ListTriggers(ctx, req)
	for {
		trigger, err := it.Next()
		if errors.Is(err, iterator.Done) {
			break
		}
		if err != nil {
			return fmt.Errorf("it.Next: %w", err)
		}
		fmt.Fprintf(w, "Trigger: %s\n", trigger.GetName())
	}

	return nil
}
```

### Python


To authenticate to Eventarc, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```python
import google.api_core.exceptions
from google.cloud import eventarc_v1

client = eventarc_v1.EventarcClient()


def list_triggers(project_id: str, location_id: str) -> None:
    """Lists Eventarc triggers in a specified project and location.

    Args:
        project_id: The Google Cloud project ID.
        location_id: The Google Cloud location or region (for example, 'us-central1' or 'global').
    """
    parent = f"projects/{project_id}/locations/{location_id}"

    request = eventarc_v1.ListTriggersRequest(parent=parent)

    try:
        response = client.list_triggers(request=request)
        for trigger in response:
            print(f"Trigger Name: {trigger.name}")
            print(f"Destination: {trigger.destination}")
    except google.api_core.exceptions.GoogleAPICallError as error:
        print(f"Error listing triggers: {error.message}")
```

## What's next


To search and filter code samples for other Google Cloud products, see the
[Google Cloud sample browser](https://docs.cloud.google.com/docs/samples.md.txt?product=eventarc).