Delete an existing Google API source in Eventarc.

## Code sample

### 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 delete_google_api_source(
    project_id: str, location_id: str, google_api_source_id: str
) -> None:
    """Deletes a Google API source in Eventarc.

    Args:
        project_id: The Google Cloud project ID hosting the GoogleApiSource.
        location_id: The Google Cloud region where the target GoogleApiSource was provisioned.
        google_api_source_id: The ID of an existing GoogleApiSource to delete.
    """
    name = (
        f"projects/{project_id}/locations/{location_id}/"
        f"googleApiSources/{google_api_source_id}"
    )

    try:
        # DeleteGoogleApiSource initiates a long-running operation
        operation = client.delete_google_api_source(name=name)
        operation.result()
        print(f"Deleted Google API source: {name}")
    except google.api_core.exceptions.GoogleAPICallError as e:
        print(f"Failed to delete Google API source: {e.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).