Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DXCDT-245: Add guide on how to retrieve available action triggers #370

Merged
merged 7 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 206 additions & 0 deletions docs/guides/action_triggers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
---
page_title: Retrieve triggers available within actions
description: |-
Retrieve the set of triggers currently available within actions.
---

# Retrieving the set of triggers available within actions

In this guide we'll show how to retrieve the set of triggers currently available within actions.
A trigger is an extensibility point to which actions can be bound.

## Get an API Explorer Token

Head to the APIs section of your [Auth0 Dashboard](https://manage.auth0.com/#/apis) and select **Auth0 Management API**.

<img alt="get_api_explorer_token_1" src="https://user-images.githubusercontent.com/28300158/196163108-1a871ae9-7d98-4c4b-bb9f-a1fbf2e3fe8f.png">

Select **Create & Authorize Test Application** within the **API Explorer** tab.

<img alt="get_api_explorer_token_2" src="https://user-images.githubusercontent.com/28300158/196164274-785a39bf-e774-4d3d-a56b-c9b2b5c9149c.png">

Copy the **Token** contents and go to the [Management API Explorer](https://auth0.com/docs/api/management/v2).

<img alt="get_api_explorer_token_3" src="https://user-images.githubusercontent.com/28300158/196165167-e0e4b86d-8536-4613-9c61-7faec6dec8f9.png">

Select **Set API Token** button at the top left.

Set the **API Token** by pasting the **Token** that you copied above.

Select **Set Token** button.

<img alt="get_api_explorer_token_4" src="https://user-images.githubusercontent.com/28300158/196165357-6a2c3b69-2219-46eb-af2b-66665945bc75.png">

Retrieve the set of triggers available within actions by selecting the **Try** button at
[https://auth0.com/docs/api/management/v2#!/Actions/get_triggers](https://auth0.com/docs/api/management/v2#!/Actions/get_triggers).

<img alt="get_api_explorer_token_5" src="https://user-images.githubusercontent.com/28300158/196166349-8e4414ab-a110-4cf6-9343-dcc75a46146d.png">

Widcket marked this conversation as resolved.
Show resolved Hide resolved
At the time of writing (_2022-10-17_) the available triggers are the following:

```json
{
"triggers": [
{
"id": "post-login",
"version": "v2",
"status": "DEPRECATED",
"runtimes": [
"node12",
"node16"
],
"default_runtime": "node16",
"compatible_triggers": []
},
{
"id": "post-login",
"version": "v3",
"status": "CURRENT",
"runtimes": [
"node12",
"node16"
],
"default_runtime": "node16",
"compatible_triggers": [
{
"id": "post-login",
"version": "v2"
}
]
},
{
"id": "post-login",
"version": "v1",
"status": "DEPRECATED",
"runtimes": [
"node12"
],
"default_runtime": "node12",
"compatible_triggers": []
},
{
"id": "credentials-exchange",
"version": "v1",
"status": "DEPRECATED",
"runtimes": [
"node12"
],
"default_runtime": "node12",
"compatible_triggers": []
},
{
"id": "credentials-exchange",
"version": "v2",
"status": "CURRENT",
"runtimes": [
"node12",
"node16"
],
"default_runtime": "node16",
"compatible_triggers": []
},
{
"id": "pre-user-registration",
"version": "v2",
"status": "CURRENT",
"runtimes": [
"node12",
"node16"
],
"default_runtime": "node16",
"compatible_triggers": []
},
{
"id": "pre-user-registration",
"version": "v1",
"status": "DEPRECATED",
"runtimes": [
"node12"
],
"default_runtime": "node12",
"compatible_triggers": []
},
{
"id": "post-user-registration",
"version": "v2",
"status": "CURRENT",
"runtimes": [
"node12",
"node16"
],
"default_runtime": "node16",
"compatible_triggers": []
},
{
"id": "post-user-registration",
"version": "v1",
"status": "DEPRECATED",
"runtimes": [
"node12"
],
"default_runtime": "node12",
"compatible_triggers": []
},
{
"id": "post-change-password",
"version": "v2",
"status": "CURRENT",
"runtimes": [
"node12",
"node16"
],
"default_runtime": "node16",
"compatible_triggers": []
},
{
"id": "post-change-password",
"version": "v1",
"status": "DEPRECATED",
"runtimes": [
"node12"
],
"default_runtime": "node12",
"compatible_triggers": []
},
{
"id": "send-phone-message",
"version": "v2",
"status": "CURRENT",
"runtimes": [
"node12",
"node16"
],
"default_runtime": "node16",
"compatible_triggers": []
},
{
"id": "send-phone-message",
"version": "v1",
"status": "DEPRECATED",
"runtimes": [
"node12"
],
"compatible_triggers": []
}
]
}
```

Use these to set up your `supported_triggers` block within the `auth0_action` resource:

```terraform
resource "auth0_action" "my_action" {
name = format("Test Action %s", timestamp())
runtime = "node16"
code = <<-EOT
exports.onExecutePostLogin = async (event, api) => {
console.log(event);
};
EOT

supported_triggers {
id = "post-login"
version = "v3"
}
}
```
2 changes: 1 addition & 1 deletion docs/guides/quickstart.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
page_title: "Getting Started"
page_title: Quickstart
description: |-
Quickly get started with the Auth0 Provider.
---
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/action.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ resource "auth0_action" "my_action" {

- `code` (String) The source code of the action.
- `name` (String) The name of the action.
- `supported_triggers` (Block List, Min: 1, Max: 1) List of triggers that this action supports. At this time, an action can only target a single trigger at a time. (see [below for nested schema](#nestedblock--supported_triggers))
- `supported_triggers` (Block List, Min: 1, Max: 1) List of triggers that this action supports. At this time, an action can only target a single trigger at a time. Read [Retrieving the set of triggers available within actions](https://registry.terraform.io/providers/auth0/auth0/latest/docs/guides/action_triggers) to retrieve the latest trigger versions supported. (see [below for nested schema](#nestedblock--supported_triggers))

### Optional

Expand Down
4 changes: 3 additions & 1 deletion internal/provider/resource_auth0_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ func newAction() *schema.Resource {
},
},
Description: "List of triggers that this action supports. " +
"At this time, an action can only target a single trigger at a time.",
"At this time, an action can only target a single trigger at a time. " +
"Read [Retrieving the set of triggers available within actions](https://registry.terraform.io/providers/auth0/auth0/latest/docs/guides/action_triggers) " +
"to retrieve the latest trigger versions supported.",
},
"code": {
Type: schema.TypeString,
Expand Down
Loading