Skip to content

Conversation

ewanharris
Copy link
Contributor

@ewanharris ewanharris commented Sep 26, 2025

🔧 Changes

Warning

This feature is currently behind a feature flag so will not work until the release is finalised

Adds support for the Organization Domain Discovery endpoints and the new property on a client that can be used to control the behaviour for discovery.

package main

import (
	"context"
	"log"

	"github.com/auth0/go-auth0"
	"github.com/auth0/go-auth0/management"
)

func main() {
	mgmt, err := management.New(
		"",
		management.WithClientCredentials(context.Background(), "", ""),
	)
	if err != nil {
		log.Fatalf("err setting up client %+v", err)
	}

	org_id := "ADD_ME"

	// cleanup
	list, err := mgmt.Organization.DiscoveryDomains(context.TODO(), org_id)
	if err != nil {
		log.Fatalf("err getting discovery domains: %+v", err)
	}
	log.Printf("found %d discovery domains", len(list.Domains))

	for _, d := range list.Domains {
		err = mgmt.Organization.DeleteDiscoveryDomain(context.TODO(), org_id, d.GetID())
		if err != nil {
			log.Fatalf("err deleting discovery domain: %+v", err)
		}
		log.Printf("deleted discovery domain: %+v", d)
	}

	domain := &management.OrganizationDiscoveryDomain{
		Domain: auth0.String("example.com"),
		Status: auth0.String("pending"),
	}

	// Create
	err = mgmt.Organization.CreateDiscoveryDomain(context.TODO(), org_id, domain)
	if err != nil {
		log.Fatalf("err creating discovery domain: %+v", err)
	}
	log.Printf("created discovery domain: %+v", domain)

	// List
	list, err = mgmt.Organization.DiscoveryDomains(context.TODO(), org_id)
	if err != nil {
		log.Fatalf("err getting discovery domains: %+v", err)
	}

	for _, d := range list.Domains {
		log.Printf("domain: %+v", d)
	}

	// update
	domain.Status = auth0.String("verified")
	err = mgmt.Organization.UpdateDiscoveryDomain(context.TODO(), org_id, domain.GetID(), domain)
	if err != nil {
		log.Fatalf("err updating discovery domain: %+v", err)
	}
	log.Printf("updated discovery domain: %+v", domain)

	// delete
	err = mgmt.Organization.DeleteDiscoveryDomain(context.TODO(), org_id, domain.GetID())
	if err != nil {
		log.Fatalf("err deleting discovery domain: %+v", err)
	}
	log.Printf("deleted discovery domain: %+v", domain)

}

📚 References

🔬 Testing

Manually tested using above script and automated tests added

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

@codecov-commenter
Copy link

codecov-commenter commented Sep 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.29%. Comparing base (3e8a482) to head (4d49691).
⚠️ Report is 6 commits behind head on v1.

Additional details and impacted files
@@            Coverage Diff             @@
##               v1     #612      +/-   ##
==========================================
+ Coverage   96.26%   96.29%   +0.02%     
==========================================
  Files          62       62              
  Lines       12893    12975      +82     
==========================================
+ Hits        12412    12494      +82     
  Misses        363      363              
  Partials      118      118              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ewanharris ewanharris force-pushed the feat/organization-domain-discovery branch from bb721d5 to 6cffdbc Compare September 30, 2025 14:41
@kushalshit27 kushalshit27 changed the base branch from main to v1 October 9, 2025 12:32
@developerkunal developerkunal marked this pull request as ready for review October 11, 2025 15:20
@developerkunal developerkunal requested a review from a team as a code owner October 11, 2025 15:20
Copy link
Contributor

@developerkunal developerkunal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants