-
Notifications
You must be signed in to change notification settings - Fork 3
docs(sdk): add KAS Registry page #276
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
Open
marythought
wants to merge
1
commit into
main
Choose a base branch
from
DSPX-2536/kas-registry-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| import Tabs from '@theme/Tabs'; | ||
| import TabItem from '@theme/TabItem'; | ||
|
|
||
| <details id="create-kas-server"> | ||
| <summary>CreateKeyAccessServer</summary> | ||
|
|
||
| Registers a new Key Access Server (KAS) with the platform. | ||
|
|
||
| **Signature** | ||
|
|
||
| <Tabs> | ||
| <TabItem value="go" label="Go"> | ||
|
|
||
| ```go | ||
| func (c KeyAccessServerRegistryServiceClient) CreateKeyAccessServer( | ||
| ctx context.Context, | ||
| req *kasregistry.CreateKeyAccessServerRequest, | ||
| ) (*kasregistry.CreateKeyAccessServerResponse, error) | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="java" label="Java"> | ||
|
|
||
| ```java | ||
| CreateKeyAccessServerResponse createKeyAccessServerBlocking( | ||
| CreateKeyAccessServerRequest request, Map<String, String> metadata | ||
| ) | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="js" label="JavaScript"> | ||
|
|
||
| ```typescript | ||
| keyAccessServerRegistry.createKeyAccessServer( | ||
| request: CreateKeyAccessServerRequest | ||
| ): Promise<CreateKeyAccessServerResponse> | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| **Parameters** | ||
|
|
||
| | Parameter | Type | Required | Description | | ||
| |-----------|------|----------|-------------| | ||
| | `uri` | `string` | Yes | URL of the KAS instance (e.g., `https://kas.example.com`). | | ||
| | `name` | `string` | No | Unique name for the KAS (alphanumeric, hyphens, underscores; max 253 chars; normalized to lowercase). | | ||
| | `source_type` | `SourceType` | No | `INTERNAL` (managed by your org) or `EXTERNAL` (managed by an external party). | | ||
| | `metadata` | `MetadataMutable` | No | Labels to attach (key-value string pairs). | | ||
|
|
||
| **Example** | ||
|
|
||
| <Tabs> | ||
| <TabItem value="go" label="Go"> | ||
|
|
||
| ```go | ||
| import ( | ||
| "github.com/opentdf/platform/protocol/go/policy" | ||
| "github.com/opentdf/platform/protocol/go/policy/kasregistry" | ||
| ) | ||
|
|
||
| resp, err := client.KeyAccessServerRegistry.CreateKeyAccessServer(context.Background(), | ||
| &kasregistry.CreateKeyAccessServerRequest{ | ||
| Uri: "https://kas.example.com", | ||
| Name: "my-kas", | ||
| SourceType: policy.SourceType_SOURCE_TYPE_INTERNAL, | ||
| }, | ||
| ) | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| log.Printf("Created KAS: %s (ID: %s)\n", resp.GetKeyAccessServer().GetName(), resp.GetKeyAccessServer().GetId()) | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="java" label="Java"> | ||
|
|
||
| ```java | ||
| import io.opentdf.platform.policy.SourceType; | ||
| import io.opentdf.platform.policy.kasregistry.CreateKeyAccessServerRequest; | ||
|
|
||
| var req = CreateKeyAccessServerRequest.newBuilder() | ||
| .setUri("https://kas.example.com") | ||
| .setName("my-kas") | ||
| .setSourceType(SourceType.SOURCE_TYPE_INTERNAL) | ||
| .build(); | ||
| var resp = sdk.getServices().kasRegistry() | ||
| .createKeyAccessServerBlocking(req, Collections.emptyMap()).execute(); | ||
| System.out.println("Created KAS: " + resp.getKeyAccessServer().getName() | ||
| + " (ID: " + resp.getKeyAccessServer().getId() + ")"); | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="js" label="JavaScript"> | ||
|
|
||
| ```typescript | ||
| import { SourceType } from '@opentdf/sdk/platform/policy/objects_pb.js'; | ||
|
|
||
| const resp = await platform.v1.keyAccessServerRegistry.createKeyAccessServer({ | ||
| uri: 'https://kas.example.com', | ||
| name: 'my-kas', | ||
| sourceType: SourceType.INTERNAL, | ||
| }); | ||
| console.log(`Created KAS: ${resp.keyAccessServer?.name} (ID: ${resp.keyAccessServer?.id})`); | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| **Returns** | ||
|
|
||
| The created `KeyAccessServer` object, including its generated `id`, `uri`, `name`, `source_type`, and `metadata` with server-set timestamps. | ||
|
|
||
| **Errors** | ||
|
|
||
| | Error | Cause | | ||
| |-------|-------| | ||
| | Already exists | A KAS with the same `uri` or `name` is already registered. | | ||
| | Invalid argument | The `uri` is not a valid URL, or the `name` violates naming constraints. | | ||
| | Permission denied | The caller lacks permission to create KAS entries. | | ||
|
|
||
| </details> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| import Tabs from '@theme/Tabs'; | ||
| import TabItem from '@theme/TabItem'; | ||
|
|
||
| <details id="list-kas-servers"> | ||
| <summary>ListKeyAccessServers</summary> | ||
|
|
||
| Returns all registered Key Access Servers, with optional pagination. | ||
|
|
||
| **Signature** | ||
|
|
||
| <Tabs> | ||
| <TabItem value="go" label="Go"> | ||
|
|
||
| ```go | ||
| func (c KeyAccessServerRegistryServiceClient) ListKeyAccessServers( | ||
| ctx context.Context, | ||
| req *kasregistry.ListKeyAccessServersRequest, | ||
| ) (*kasregistry.ListKeyAccessServersResponse, error) | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="java" label="Java"> | ||
|
|
||
| ```java | ||
| ListKeyAccessServersResponse listKeyAccessServersBlocking( | ||
| ListKeyAccessServersRequest request, Map<String, String> metadata | ||
| ) | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="js" label="JavaScript"> | ||
|
|
||
| ```typescript | ||
| keyAccessServerRegistry.listKeyAccessServers( | ||
| request: ListKeyAccessServersRequest | ||
| ): Promise<ListKeyAccessServersResponse> | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| **Parameters** | ||
|
|
||
| | Parameter | Type | Required | Description | | ||
| |-----------|------|----------|-------------| | ||
| | `pagination.limit` | `int32` | No | Maximum number of results to return. | | ||
| | `pagination.offset` | `int32` | No | Number of results to skip. | | ||
|
|
||
| **Example** | ||
|
|
||
| <Tabs> | ||
| <TabItem value="go" label="Go"> | ||
|
|
||
| ```go | ||
| import "github.com/opentdf/platform/protocol/go/policy/kasregistry" | ||
|
|
||
| resp, err := client.KeyAccessServerRegistry.ListKeyAccessServers(context.Background(), | ||
| &kasregistry.ListKeyAccessServersRequest{}, | ||
| ) | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| for _, kas := range resp.GetKeyAccessServers() { | ||
| log.Printf("KAS: %s — %s (source: %s)\n", kas.GetName(), kas.GetUri(), kas.GetSourceType()) | ||
| } | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="java" label="Java"> | ||
|
|
||
| ```java | ||
| import io.opentdf.platform.policy.kasregistry.ListKeyAccessServersRequest; | ||
|
|
||
| var req = ListKeyAccessServersRequest.newBuilder().build(); | ||
| var resp = sdk.getServices().kasRegistry() | ||
| .listKeyAccessServersBlocking(req, Collections.emptyMap()).execute(); | ||
|
Comment on lines
+75
to
+76
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| for (var kas : resp.getKeyAccessServersList()) { | ||
| System.out.println("KAS: " + kas.getName() + " — " + kas.getUri() | ||
| + " (source: " + kas.getSourceType() + ")"); | ||
| } | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="js" label="JavaScript"> | ||
|
|
||
| ```typescript | ||
| const resp = await platform.v1.keyAccessServerRegistry.listKeyAccessServers({}); | ||
| for (const kas of resp.keyAccessServers) { | ||
| console.log(`KAS: ${kas.name} — ${kas.uri} (source: ${kas.sourceType})`); | ||
| } | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| **Returns** | ||
|
|
||
| A list of `KeyAccessServer` objects and a `pagination` response containing `current_offset`, `next_offset`, and `total` count. | ||
|
|
||
| **Errors** | ||
|
|
||
| | Error | Cause | | ||
| |-------|-------| | ||
| | Permission denied | The caller lacks permission to list KAS entries. | | ||
|
|
||
| </details> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Java SDK's blocking service methods return the response object directly. Calling
.execute()on the result ofcreateKeyAccessServerBlockingis incorrect as it contradicts the method signature provided in the documentation above.