Retrieve details about an existing Eventarc Google API source.

## 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"
	"fmt"
	"io"

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

// getGoogleApiSource retrieves a Google API source in Eventarc.
func getGoogleApiSource(ctx context.Context, w io.Writer, projectID string, locationID string, googleAPISourceID string) error {
	name := fmt.Sprintf("projects/%s/locations/%s/googleApiSources/%s", projectID, locationID, googleAPISourceID)

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

	req := &eventarcpb.GetGoogleApiSourceRequest{
		Name: name,
	}

	source, err := client.GetGoogleApiSource(ctx, req)
	if err != nil {
		return fmt.Errorf("client.GetGoogleApiSource failed: %w", err)
	}

	fmt.Fprintf(w, "Retrieved Google API source: %s\n", source.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 get_google_api_source(
    project_id: str, location_id: str, google_api_source_id: str
) -> None:
    """Retrieves a Google API source in Eventarc.

    Args:
        project_id: The Google Cloud project ID.
        location_id: The Google Cloud region for the resource.
        google_api_source_id: The user-provided or existing ID of the GoogleApiSource to retrieve.
    """
    name = f"projects/{project_id}/locations/{location_id}/googleApiSources/{google_api_source_id}"
    request = eventarc_v1.GetGoogleApiSourceRequest(name=name)

    try:
        response = client.get_google_api_source(request=request)
        print(f"Retrieved Google API source: {response.name}")
        print(f"Destination: {response.destination}")
        print(f"Crypto key name: {response.crypto_key_name}")
    except google.api_core.exceptions.GoogleAPICallError as error:
        print(f"Failed to retrieve Google API source: {error}")
```

## 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).