From a1688935e58cacb0a45ce77124e2a832b03fec56 Mon Sep 17 00:00:00 2001
From: b-long <b-long@users.noreply.github.com>
Date: Mon, 7 Jul 2025 16:13:23 -0400
Subject: [PATCH 1/7] Set 'platformEndpoint' consistently

---
 code_samples/policy_code/create_namespace.mdx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/code_samples/policy_code/create_namespace.mdx b/code_samples/policy_code/create_namespace.mdx
index ed523aa4..403293da 100644
--- a/code_samples/policy_code/create_namespace.mdx
+++ b/code_samples/policy_code/create_namespace.mdx
@@ -19,7 +19,7 @@ import (
 
 func main() {
 
-	platformEndpoint := "https://opentdf.io"
+	platformEndpoint := "http://localhost:9002"
 
 	// Create a new client
 	client, err := sdk.New(

From e5a42573f7c4c071072617b25c2d78a62100e9f7 Mon Sep 17 00:00:00 2001
From: b-long <b-long@users.noreply.github.com>
Date: Mon, 7 Jul 2025 16:25:27 -0400
Subject: [PATCH 2/7] Use dynamic namespaceID in 'create_attribute' example

---
 code_samples/policy_code/create_attribute.mdx | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/code_samples/policy_code/create_attribute.mdx b/code_samples/policy_code/create_attribute.mdx
index 798482dc..4efefc87 100644
--- a/code_samples/policy_code/create_attribute.mdx
+++ b/code_samples/policy_code/create_attribute.mdx
@@ -15,6 +15,7 @@ import (
 
 	"github.com/opentdf/platform/protocol/go/policy"
 	"github.com/opentdf/platform/protocol/go/policy/attributes"
+	"github.com/opentdf/platform/protocol/go/policy/namespaces"
 	"github.com/opentdf/platform/sdk"
 )
 
@@ -32,9 +33,19 @@ func main() {
 		log.Fatal(err)
 	}
 
-	// Create a new attribute
-	namespaceID := "f9ac9403-a12f-4ed3-b3c9-a46910361b4d"
+	// List namespaces to get a namespace ID
+	listResponse, err := client.Namespaces.ListNamespaces(context.Background(), &namespaces.ListNamespacesRequest{})
+	if err != nil {
+		log.Fatalf("failed to list namespaces: %s", err)
+	}
 
+	if len(listResponse.GetNamespaces()) == 0 {
+		log.Fatal("no namespaces found")
+	}
+
+	namespaceID := listResponse.GetNamespaces()[0].GetId()
+
+	// Create a new attribute
 	attrRequest := &attributes.CreateAttributeRequest{
 		NamespaceId: namespaceID,
 		Name:        "role",
@@ -42,10 +53,11 @@ func main() {
 		Values:      []string{"admin", "developer", "guest"},
 	}
 
-	_, err = client.Attributes.CreateAttribute(context.Background(), attrRequest)
+	attribute, err := client.Attributes.CreateAttribute(context.Background(), attrRequest)
 	if err != nil {
 		log.Fatal(err)
 	}
+	log.Printf("Created attribute: %s with ID: %s in namespace: %s\n", "role", attribute.GetAttribute().GetId(), namespaceID)
 }
 ```
 

From 7b414d23a67cbbacb1d8517a0af2dad0f33599b5 Mon Sep 17 00:00:00 2001
From: b-long <b-long@users.noreply.github.com>
Date: Mon, 7 Jul 2025 16:49:07 -0400
Subject: [PATCH 3/7] Use dynamic role name in 'create_attribute' example

---
 code_samples/policy_code/create_attribute.mdx | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/code_samples/policy_code/create_attribute.mdx b/code_samples/policy_code/create_attribute.mdx
index 4efefc87..8a5710c1 100644
--- a/code_samples/policy_code/create_attribute.mdx
+++ b/code_samples/policy_code/create_attribute.mdx
@@ -11,6 +11,7 @@ package main
 
 import (
 	"context"
+	"crypto/rand"
 	"log"
 
 	"github.com/opentdf/platform/protocol/go/policy"
@@ -48,7 +49,7 @@ func main() {
 	// Create a new attribute
 	attrRequest := &attributes.CreateAttributeRequest{
 		NamespaceId: namespaceID,
-		Name:        "role",
+		Name:        "role" + "-" + rand.Text()[:4],
 		Rule:        policy.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_ANY_OF,
 		Values:      []string{"admin", "developer", "guest"},
 	}
@@ -57,7 +58,7 @@ func main() {
 	if err != nil {
 		log.Fatal(err)
 	}
-	log.Printf("Created attribute: %s with ID: %s in namespace: %s\n", "role", attribute.GetAttribute().GetId(), namespaceID)
+	log.Printf("Created attribute: %s with ID: %s in namespace: %s\n", attribute.GetAttribute().Name, attribute.GetAttribute().GetId(), namespaceID)
 }
 ```
 

From f42e0f0049319f760f5464f3e7c1903969292289 Mon Sep 17 00:00:00 2001
From: b-long <b-long@users.noreply.github.com>
Date: Mon, 7 Jul 2025 17:05:01 -0400
Subject: [PATCH 4/7] Add information for DX/learning in
 create_subject_condition

---
 code_samples/policy_code/create_subject_condition_set.mdx | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/code_samples/policy_code/create_subject_condition_set.mdx b/code_samples/policy_code/create_subject_condition_set.mdx
index 4916fed3..b84851a0 100644
--- a/code_samples/policy_code/create_subject_condition_set.mdx
+++ b/code_samples/policy_code/create_subject_condition_set.mdx
@@ -55,11 +55,12 @@ func main() {
 		},
 	}
 
-	_, err = client.SubjectMapping.CreateSubjectConditionSet(context.Background(), coditionset)
+	log, err := client.SubjectMapping.CreateSubjectConditionSet(context.Background(), coditionset)
 	if err != nil {
 		log.Fatal(err)
 	}
 
+	log.Printf("Created Subject Condition Set with ID: %s\n", resp.GetSubjectConditionSet().GetId())
 }
 ```
 

From a856c751721d444c22684a13957e349a6956b078 Mon Sep 17 00:00:00 2001
From: b-long <b-long@users.noreply.github.com>
Date: Tue, 8 Jul 2025 12:13:18 -0400
Subject: [PATCH 5/7] Fix broken link

---
 docs/components/authorization.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/components/authorization.md b/docs/components/authorization.md
index dc080044..97a41713 100644
--- a/docs/components/authorization.md
+++ b/docs/components/authorization.md
@@ -24,7 +24,7 @@ Two versions of Authorization Service are currently served simultaneously by the
 Version 2 of Authorization Service introduced the following changes:
 - consideration of policy [actions](./policy/actions.md) contained in [subject mappings](./policy/subject_mappings.md) within entitlement decisioning
 - API structure and clarity improvements
-  - [entity identifier](#entityidentifier)
+  - [entity identifier](#entity-identifier)
   - multiplexing design within decisioning
   - removal of scopes when retrieving entitlements, in deference to decision APIs
 

From 8da6e974ddba26548f479fb42fb1b1d3af4053f7 Mon Sep 17 00:00:00 2001
From: b-long <b-long@users.noreply.github.com>
Date: Wed, 9 Jul 2025 10:20:50 -0400
Subject: [PATCH 6/7] Simplify code, use 'platformEndpoint' variable

---
 code_samples/tdf/encryption_ztdf.mdx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/code_samples/tdf/encryption_ztdf.mdx b/code_samples/tdf/encryption_ztdf.mdx
index 1634448e..d8f315e9 100644
--- a/code_samples/tdf/encryption_ztdf.mdx
+++ b/code_samples/tdf/encryption_ztdf.mdx
@@ -43,7 +43,7 @@ func main() {
 		//sdk.WithDataAttributes("https://opentdf.io/attr/role/value/developer"),
 		sdk.WithKasInformation(
 			sdk.KASInfo{
-				URL: "http://localhost:9002",
+				URL: platformEndpoint,
 			},
 		),
 	)

From 4b64954247026e678d89a903499854720fb31446 Mon Sep 17 00:00:00 2001
From: b-long <b-long@users.noreply.github.com>
Date: Wed, 9 Jul 2025 13:45:12 -0400
Subject: [PATCH 7/7] Improve go example in
 'code_samples/tdf/encryption_ztdf.mdx'

---
 code_samples/tdf/encryption_ztdf.mdx | 35 +++++++++++++++-------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/code_samples/tdf/encryption_ztdf.mdx b/code_samples/tdf/encryption_ztdf.mdx
index d8f315e9..34373670 100644
--- a/code_samples/tdf/encryption_ztdf.mdx
+++ b/code_samples/tdf/encryption_ztdf.mdx
@@ -10,36 +10,37 @@ import TabItem from '@theme/TabItem';
 package main
 
 import (
-	"bufio"
 	"bytes"
 	"log"
-	"os"
 	"strings"
 
 	"github.com/opentdf/platform/sdk"
 )
 
 func main() {
+	log.Println("🚀 Starting OpenTDF example...")
 
 	platformEndpoint := "http://localhost:9002"
+	log.Printf("📡 Connecting to platform: %s", platformEndpoint)
 
 	// Create a new client
+	log.Println("🔐 Initializing new SDK client...")
 	client, err := sdk.New(
 		platformEndpoint,
 		sdk.WithClientCredentials("opentdf", "secret", nil),
 	)
 
 	if err != nil {
-		log.Fatal(err)
+		log.Fatalf("❌ Client initialization failed: %v", err)
 	}
 
 	// Encrypt ztdf
-
+	log.Println("📝 Preparing sensitive data for encryption...")
 	str := strings.NewReader("Sensitive data!")
 	buf := &bytes.Buffer{}
-	out := bufio.NewWriter(buf)
 
-	manifest, err := client.CreateTDF(out, str,
+	log.Println("🔒 Encrypting data...")
+	manifest, err := client.CreateTDF(buf, str,
 		//sdk.WithDataAttributes("https://opentdf.io/attr/role/value/developer"),
 		sdk.WithKasInformation(
 			sdk.KASInfo{
@@ -49,25 +50,27 @@ func main() {
 	)
 
 	if err != nil {
-		log.Fatal(err)
+		log.Fatalf("❌ Encryption failed: %v", err)
 	}
 
-	//Flush data to buffer
-	out.Flush()
-
-	log.Printf("TDF Manifest: %v", manifest)
+	log.Println("✅ Data successfully encrypted")
+	log.Printf("📋 TDF Manifest details:\n\n%v\n\n", manifest)
 
 	// Decrypt ztdf
+	log.Println("🔓 Decrypting data...")
 	tdfReader, err := client.LoadTDF(bytes.NewReader(buf.Bytes()))
 	if err != nil {
-		log.Fatal(err)
+		log.Fatalf("❌ Decryption failed: %v", err)
 	}
 
-	// Write decrypted data to stdout
-	_, err = tdfReader.WriteTo(os.Stdout)
-	if err != nil {
-		log.Fatal(err)
+	// Create a buffer to capture the decrypted data
+	var decryptedBuf bytes.Buffer
+	if _, err = tdfReader.WriteTo(&decryptedBuf); err != nil {
+		log.Fatalf("❌ Failed to write decrypted data: %v", err)
 	}
+
+	log.Printf("📤 Decrypted content: \n\n%s\n\n", decryptedBuf.String())
+	log.Println("✅ Example complete!")
 }
 ```
 
