Skip to content

Latest commit

 

History

History
65 lines (48 loc) · 1.18 KB

File metadata and controls

65 lines (48 loc) · 1.18 KB

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

List Attributes
package main

import (
	"context"
	"log"

	"github.com/opentdf/platform/protocol/go/policy/attributes"
	"github.com/opentdf/platform/sdk"
)

func main() {

	platformEndpoint := "http://localhost:8080"

	// Create a new client
	client, err := sdk.New(
		platformEndpoint,
		sdk.WithClientCredentials("opentdf", "secret", nil),
	)

	if err != nil {
		log.Fatal(err)
	}

	// List attributes

	attrs, err := client.Attributes.ListAttributes(context.Background(), &attributes.ListAttributesRequest{})
	if err != nil {
		log.Fatal(err)
	}

	for _, attr := range attrs.GetAttributes() {
		log.Printf("Attribute: %s, ID: %s, ", attr.GetName(), attr.GetId())
		for _, value := range attr.Values {
			log.Printf("Value: %s, ID: %s", value.GetValue(), value.GetId())
		}
	}
}

import ListAttributesExample from '@site/code_samples/java/list-attributes.mdx';