Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Esta página
se aplica à Apigee e à Apigee híbrida.
O hub de API é compatível com gatilhos Eventarc. Ao usar esse recurso, você pode acionar execuções com base nos eventos que ocorrem no hub de API. Por exemplo, você pode executar um serviço do Cloud Run quando uma API é criada no API Hub.
Este guia de início rápido mostra como criar e configurar um gatilho Eventarc que executa um serviço Cloud Run quando uma API é atualizada no API Hub.
Antes de começar
O hub de APIs precisa ser provisionado em um projeto do Google Cloud a que você tem acesso.
Consulte Provisionar hub da API.
No console do Google Cloud, na página do seletor de projetos, selecione o projeto em que o hub de APIs está provisionado.
Você precisa ter um serviço válido do Cloud Run em execução. Você usará os detalhes do serviço Cloud Run ao configurar o gatilho do Eventarc. Este é o serviço que será executado quando ocorrer o evento configurado.
Criar um gatilho do Eventarc
No Console do Google Cloud, acesse a página Gatilhos do Eventarc.
Insira o nome de um acionador.
Por exemplo, cloudrun-trigger-1.
Na lista Tipo de gatilho,
selecione Origens do Google..
Ele filtra eventos enviados por provedores do Google Cloud
(diretamente ou por entradas dos Registros de auditoria do Cloud) ou provedores que usam
mensagens do Pub/Sub.
Na lista Provedor de eventos, selecione Hub de API.
Na lista Tipo de evento, selecione google.cloud.apihub.v1.updated.
Na lista Tipo de dados de conteúdo do evento, selecione JSON ou Protobuf.
Selecione uma Região.
Opcionalmente, Adicione filtros para selecionar as APIs que correspondem aos seus critérios. Por exemplo, se você filtrar as APIs por um nome específico, o evento será acionado somente se as APIs que correspondem aos critérios de filtro forem atualizadas.
Se solicitado, conceda o seguinte:
Papel iam.serviceAccountTokenCreator para a conta de serviço do Pub/Sub
Papel pubsub.publisher para a conta de serviço do Cloud Storage
Use a conta de serviço de computação padrão como a conta de serviço que
invoca o serviço.
Na lista Destino do evento, selecione Cloud Run.
Selecione um serviço do Cloud Run que será executado quando o evento google.cloud.apihub.v1.updated ocorrer no hub de API.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-04 UTC."],[[["\u003cp\u003eThis guide details how to use Eventarc triggers with API hub to automate actions, such as executing a Cloud Run service when an API is updated.\u003c/p\u003e\n"],["\u003cp\u003eBefore creating an Eventarc trigger, you must provision API hub in a Google Cloud project and have a running Cloud Run service.\u003c/p\u003e\n"],["\u003cp\u003eTo create an Eventarc trigger, navigate to the Eventarc Triggers page in the Google Cloud console, and select API hub as the event provider and an API update event as the trigger.\u003c/p\u003e\n"],["\u003cp\u003eYou can optionally filter the APIs that trigger the event, like using the name of the APIs, and configure the specific Cloud Run service to execute when an API update occurs.\u003c/p\u003e\n"],["\u003cp\u003eThe guide is applicable to Apigee and Apigee hybrid users.\u003c/p\u003e\n"]]],[],null,["# Create an Eventarc trigger\n\n*This page\napplies to **Apigee** and **Apigee hybrid**.*\n\nAPI hub supports [Eventarc triggers](/eventarc/docs/overview#eventarc-triggers). By\nusing this feature, you can trigger executions based on the events occurring in API hub. For\nexample, you can execute a [Cloud Run](/run/docs/overview/what-is-cloud-run) service when\nan API is created in API hub.\n\nThis quickstart shows you how to create and configure an Eventarc trigger that executes a Cloud Run\nservice when an API is updated in API hub.\n\nBefore you begin\n----------------\n\n1. API hub must be provisioned in a Google Cloud project to which you have access. See [Provision API hub](/apigee/docs/apihub/provision).\n2. In the Google Cloud console, on the project selector page, select the project in which API\n hub is provisioned.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n3. You must have a valid Cloud Run service running. You will use the Cloud Run service details when configuring the Eventarc trigger. This is the service that will be executed when the configured event occurs.\n\nCreate an Eventarc trigger\n--------------------------\n\n1. In the Google Cloud console, go to the Eventarc **Triggers** page.\n\n [Go to Triggers](https://console.cloud.google.com/eventarc/triggers)\n2. Click add_box **Create trigger**.\n3. Enter a **Trigger name** . For example, `cloudrun-trigger-1`.\n4. In the **Trigger type** list, select **Google sources** .\n\n This filters events sent from Google Cloud providers (directly or\n through Cloud Audit Logs entries), or providers using Pub/Sub\n messages.\n5. In the **Event provider** list, select **API hub**.\n6. In the **Event type** list, select **google.cloud.apihub.v1.updated**.\n7. In the **Event content data type** list, select either `JSON` or `Protobuf`.\n8. Select a **Region**.\n9. Optionally, **Add filters** to select the APIs that match your criteria. For example, if you filter the APIs by a specific name, the event is triggered only if the APIs matching the filter criteria are updated.\n10. If prompted, grant the following:\n - `iam.serviceAccountTokenCreator` role to Pub/Sub service account\n - `pubsub.publisher` role to Cloud Storage service account\n11. Use the **Default compute service account** as the service account that invokes your service.\n12. In the **Event destination** list, select **Cloud Run**.\n13. Select a Cloud Run service that should be executed when the `google.cloud.apihub.v1.updated` event occurs in API hub.\n14. Optionally, enter the **Service URL path**.\n15. Click **Create**."]]