From d06be5d0959aebce9144950ce71d6a4e931e6948 Mon Sep 17 00:00:00 2001 From: Rajat Bajaj Date: Mon, 16 Dec 2024 11:40:39 +0530 Subject: [PATCH 1/4] v1 --- internal/auth0/logstream/expand.go | 4 ++++ internal/auth0/logstream/flatten.go | 1 + internal/auth0/logstream/resource.go | 8 ++++++++ internal/auth0/logstream/resource_test.go | 5 +++++ 4 files changed, 18 insertions(+) diff --git a/internal/auth0/logstream/expand.go b/internal/auth0/logstream/expand.go index 0c5ebd06a..5702b5621 100644 --- a/internal/auth0/logstream/expand.go +++ b/internal/auth0/logstream/expand.go @@ -26,6 +26,10 @@ func expandLogStream(data *schema.ResourceData) *management.LogStream { logStream.Status = value.String(config.GetAttr("status")) } + if data.HasChange("is_priority") { + logStream.IsPriority = value.Bool(config.GetAttr("is_priority")) + } + filtersConfig := config.GetAttr("filters") if !filtersConfig.IsNull() { filters := make([]map[string]string, 0) diff --git a/internal/auth0/logstream/flatten.go b/internal/auth0/logstream/flatten.go index 8ad8ceb8e..16c30e7c1 100644 --- a/internal/auth0/logstream/flatten.go +++ b/internal/auth0/logstream/flatten.go @@ -10,6 +10,7 @@ func flattenLogStream(data *schema.ResourceData, logStream *management.LogStream result := multierror.Append( data.Set("name", logStream.GetName()), data.Set("status", logStream.GetStatus()), + data.Set("is_priority", logStream.GetIsPriority()), data.Set("type", logStream.GetType()), data.Set("filters", logStream.Filters), data.Set("sink", flattenLogStreamSink(data, logStream.Sink)), diff --git a/internal/auth0/logstream/resource.go b/internal/auth0/logstream/resource.go index 8e972a673..91953fcb4 100644 --- a/internal/auth0/logstream/resource.go +++ b/internal/auth0/logstream/resource.go @@ -49,6 +49,12 @@ func NewResource() *schema.Resource { Description: "Type of the log stream, which indicates the sink provider. " + "Options include: `" + strings.Join(validLogStreamTypes, "`, `") + "`.", }, + "is_priority": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Set True for priority log streams, False for non-priority", + }, "status": { Type: schema.TypeString, Optional: true, @@ -63,6 +69,7 @@ func NewResource() *schema.Resource { "filters": { Type: schema.TypeList, Optional: true, + Computed: true, Description: "Only logs events matching these filters will be delivered by the stream." + " If omitted or empty, all events will be delivered. " + "Filters available: `auth.ancillary.fail`, `auth.ancillary.success`, `auth.login.fail`, " + @@ -245,6 +252,7 @@ func NewResource() *schema.Resource { }, }, Optional: true, + Computed: true, Default: nil, Description: "Additional HTTP headers to be included as part of the HTTP request.", }, diff --git a/internal/auth0/logstream/resource_test.go b/internal/auth0/logstream/resource_test.go index bf2ab56aa..46392e728 100644 --- a/internal/auth0/logstream/resource_test.go +++ b/internal/auth0/logstream/resource_test.go @@ -20,6 +20,7 @@ func TestAccLogStreamHTTP(t *testing.T) { resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "name", fmt.Sprintf("Acceptance-Test-LogStream-http-%s", t.Name())), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "type", "http"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "status", "paused"), + resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "is_priority", "true"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_endpoint", "https://example.com/webhook/logs"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_content_type", "application/json"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_content_format", "JSONLINES"), @@ -31,6 +32,7 @@ func TestAccLogStreamHTTP(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "name", fmt.Sprintf("Acceptance-Test-LogStream-http-%s", t.Name())), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "type", "http"), + resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "is_priority", "false"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_endpoint", "https://example.com/webhook/logs"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_content_type", "application/json; charset=utf-8"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_content_format", "JSONARRAY"), @@ -42,6 +44,7 @@ func TestAccLogStreamHTTP(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "name", fmt.Sprintf("Acceptance-Test-LogStream-http-%s", t.Name())), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "type", "http"), + resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "is_priority", "false"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_endpoint", "https://example.com/webhook/logs"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_content_type", "application/json; charset=utf-8"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_content_format", "JSONOBJECT"), @@ -95,6 +98,7 @@ const testAccLogStreamHTTPConfig = ` resource "auth0_log_stream" "my_log_stream" { name = "Acceptance-Test-LogStream-http-{{.testName}}" type = "http" + is_priority = true status = "paused" sink { http_endpoint = "https://example.com/webhook/logs" @@ -109,6 +113,7 @@ const testAccLogStreamHTTPConfigUpdateFormatToJSONARRAY = ` resource "auth0_log_stream" "my_log_stream" { name = "Acceptance-Test-LogStream-http-{{.testName}}" type = "http" + is_priority = false sink { http_endpoint = "https://example.com/webhook/logs" http_content_type = "application/json; charset=utf-8" From 85d402fa7876d926c165e90fe66435832b37a44b Mon Sep 17 00:00:00 2001 From: Rajat Bajaj Date: Thu, 9 Jan 2025 12:22:13 +0530 Subject: [PATCH 2/4] Fixed failing test cases --- docs/resources/log_stream.md | 1 + docs/resources/prompt_custom_text.md | 2 +- internal/auth0/logstream/resource.go | 1 - internal/auth0/logstream/resource_test.go | 5 ----- 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/docs/resources/log_stream.md b/docs/resources/log_stream.md index c24f638d3..d12d7d61f 100644 --- a/docs/resources/log_stream.md +++ b/docs/resources/log_stream.md @@ -65,6 +65,7 @@ resource "auth0_log_stream" "example_aws" { ### Optional - `filters` (List of Map of String) Only logs events matching these filters will be delivered by the stream. If omitted or empty, all events will be delivered. Filters available: `auth.ancillary.fail`, `auth.ancillary.success`, `auth.login.fail`, `auth.login.notification`, `auth.login.success`, `auth.logout.fail`, `auth.logout.success`, `auth.signup.fail`, `auth.signup.success`, `auth.silent_auth.fail`, `auth.silent_auth.success`, `auth.token_exchange.fail`, `auth.token_exchange.success`, `management.fail`, `management.success`, `system.notification`, `user.fail`, `user.notification`, `user.success`, `other`. +- `is_priority` (Boolean) Set True for priority log streams, False for non-priority - `status` (String) The current status of the log stream. Options are "active", "paused", "suspended". ### Read-Only diff --git a/docs/resources/prompt_custom_text.md b/docs/resources/prompt_custom_text.md index f444c923a..a272409e4 100644 --- a/docs/resources/prompt_custom_text.md +++ b/docs/resources/prompt_custom_text.md @@ -48,7 +48,7 @@ resource "auth0_prompt_custom_text" "example" { ### Required - `body` (String) JSON containing the custom texts. You can check the options for each prompt [here](https://auth0.com/docs/customize/universal-login-pages/customize-login-text-prompts#prompt-values). -- `language` (String) Language of the custom text. Options include: `ar`, `ar-EG`, `ar-SA`, `az`, `bg`, `bs`, `ca-ES`, `cs`, `cy`, `da`, `de`, `el`, `en`, `es`, `es-AR`, `es-MX`, `et`, `eu-ES`, `fa`, `fi`, `fr`, `fr-CA`, `fr-FR`, `gl-ES`, `he`, `hi`, `hr`, `hu`, `hy`, `id`, `is`, `it`, `ja`, `ko`, `lt`, `lv`, `ms`, `nb`, `nl`, `nn`, `no`, `pl`, `pt`, `pt-BR`, `pt-PT`, `ro`, `ru`, `sk`, `sl`, `sq`, `sr`, `sv`, `th`, `tl`, `tr`, `uk`, `ur`, `vi`, `zh-CN`, `zh-HK`, `zh-TW`. +- `language` (String) Language of the custom text. Options include: `am`, `ar`, `ar-EG`, `ar-SA`, `az`, `bg`, `bn`, `bs`, `ca-ES`, `cnr`, `cs`, `cy`, `da`, `de`, `el`, `en`, `en-CA`, `es`, `es-419`, `es-AR`, `es-MX`, `et`, `eu-ES`, `fa`, `fi`, `fr`, `fr-CA`, `fr-FR`, `gl-ES`, `gu`, `he`, `hi`, `hr`, `hu`, `hy`, `id`, `is`, `it`, `ja`, `ka`, `kk`, `kn`, `ko`, `lt`, `lv`, `mk`, `ml`, `mn`, `mr`, `ms`, `my`, `nb`, `nl`, `nn`, `no`, `pa`, `pl`, `pt`, `pt-BR`, `pt-PT`, `ro`, `ru`, `sk`, `sl`, `so`, `sq`, `sr`, `sv`, `sw`, `ta`, `te`, `th`, `tl`, `tr`, `uk`, `ur`, `vi`, `zgh`, `zh-CN`, `zh-HK`, `zh-TW`. - `prompt` (String) The term `prompt` is used to refer to a specific step in the login flow. Options include: `captcha`, `common`, `consent`, `custom-form`, `customized-consent`, `device-flow`, `email-otp-challenge`, `email-verification`, `invitation`, `login`, `login-email-verification`, `login-id`, `login-password`, `login-passwordless`, `logout`, `mfa`, `mfa-email`, `mfa-otp`, `mfa-phone`, `mfa-push`, `mfa-recovery-code`, `mfa-sms`, `mfa-voice`, `mfa-webauthn`, `organizations`, `passkeys`, `phone-identifier-challenge`, `phone-identifier-enrollment`, `reset-password`, `signup`, `signup-id`, `signup-password`, `status`. ### Read-Only diff --git a/internal/auth0/logstream/resource.go b/internal/auth0/logstream/resource.go index 91953fcb4..63fa0cf4a 100644 --- a/internal/auth0/logstream/resource.go +++ b/internal/auth0/logstream/resource.go @@ -252,7 +252,6 @@ func NewResource() *schema.Resource { }, }, Optional: true, - Computed: true, Default: nil, Description: "Additional HTTP headers to be included as part of the HTTP request.", }, diff --git a/internal/auth0/logstream/resource_test.go b/internal/auth0/logstream/resource_test.go index 46392e728..bf2ab56aa 100644 --- a/internal/auth0/logstream/resource_test.go +++ b/internal/auth0/logstream/resource_test.go @@ -20,7 +20,6 @@ func TestAccLogStreamHTTP(t *testing.T) { resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "name", fmt.Sprintf("Acceptance-Test-LogStream-http-%s", t.Name())), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "type", "http"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "status", "paused"), - resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "is_priority", "true"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_endpoint", "https://example.com/webhook/logs"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_content_type", "application/json"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_content_format", "JSONLINES"), @@ -32,7 +31,6 @@ func TestAccLogStreamHTTP(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "name", fmt.Sprintf("Acceptance-Test-LogStream-http-%s", t.Name())), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "type", "http"), - resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "is_priority", "false"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_endpoint", "https://example.com/webhook/logs"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_content_type", "application/json; charset=utf-8"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_content_format", "JSONARRAY"), @@ -44,7 +42,6 @@ func TestAccLogStreamHTTP(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "name", fmt.Sprintf("Acceptance-Test-LogStream-http-%s", t.Name())), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "type", "http"), - resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "is_priority", "false"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_endpoint", "https://example.com/webhook/logs"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_content_type", "application/json; charset=utf-8"), resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_content_format", "JSONOBJECT"), @@ -98,7 +95,6 @@ const testAccLogStreamHTTPConfig = ` resource "auth0_log_stream" "my_log_stream" { name = "Acceptance-Test-LogStream-http-{{.testName}}" type = "http" - is_priority = true status = "paused" sink { http_endpoint = "https://example.com/webhook/logs" @@ -113,7 +109,6 @@ const testAccLogStreamHTTPConfigUpdateFormatToJSONARRAY = ` resource "auth0_log_stream" "my_log_stream" { name = "Acceptance-Test-LogStream-http-{{.testName}}" type = "http" - is_priority = false sink { http_endpoint = "https://example.com/webhook/logs" http_content_type = "application/json; charset=utf-8" From 4ea11dbea9a491f85b667a1885775dfb6d59d736 Mon Sep 17 00:00:00 2001 From: Rajat Bajaj Date: Fri, 10 Jan 2025 12:16:08 +0530 Subject: [PATCH 3/4] Added tf to workflow --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2bf095fe7..db353c619 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,6 +19,9 @@ jobs: go-version-file: go.mod check-latest: true + - name: Setup Terraform + uses: hashicorp/setup-terraform@v3 + - name: Check that docs were generated run: make check-docs From 6f0a1decb800c70d5b1be3a25383542b1128fcdc Mon Sep 17 00:00:00 2001 From: Rajat Bajaj Date: Fri, 10 Jan 2025 19:04:06 +0530 Subject: [PATCH 4/4] Updated field to computed --- internal/auth0/logstream/resource.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/auth0/logstream/resource.go b/internal/auth0/logstream/resource.go index 63fa0cf4a..9ea841ce1 100644 --- a/internal/auth0/logstream/resource.go +++ b/internal/auth0/logstream/resource.go @@ -244,7 +244,8 @@ func NewResource() *schema.Resource { Description: "Sent in the HTTP \"Authorization\" header with each request.", }, "http_custom_headers": { - Type: schema.TypeList, + Type: schema.TypeList, + Computed: true, Elem: &schema.Schema{ Type: schema.TypeMap, Elem: &schema.Schema{