Rename CLI trust-center commands

Replace the trust-center command tree with
compliance-portal so the CLI matches the
product and GraphQL rename.

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-07-20 18:08:22 +02:00
parent 8773a54396
commit 263ea61aba
27 changed files with 183 additions and 183 deletions

View File

@@ -0,0 +1,45 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package commitment
import (
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cmd/cmdutil"
"go.probo.inc/probo/pkg/cmd/compliance-portal/commitment/create"
"go.probo.inc/probo/pkg/cmd/compliance-portal/commitment/delete"
"go.probo.inc/probo/pkg/cmd/compliance-portal/commitment/list"
"go.probo.inc/probo/pkg/cmd/compliance-portal/commitment/update"
)
func NewCmdCommitment(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "commitment <command>",
Short: "Manage compliance portal commitments",
Aliases: []string{"cmt"},
}
cmd.AddCommand(list.NewCmdList(f))
cmd.AddCommand(create.NewCmdCreate(f))
cmd.AddCommand(update.NewCmdUpdate(f))
cmd.AddCommand(delete.NewCmdDelete(f))
return cmd
}

View File

@@ -0,0 +1,246 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package create
import (
"encoding/json"
"fmt"
"github.com/charmbracelet/huh"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
)
var validIcons = []string{
"LOCK_KEY",
"EYE_SLASH",
"FINGERPRINT",
"SHIELD_WARNING",
"SHIELD_CHECK",
"SIREN",
"KEY",
"LOCK",
"CLOUD",
"DATABASE",
"GLOBE",
"EYE",
"USERS",
"CERTIFICATE",
"GAVEL",
"HEARTBEAT",
"BELL",
"BUG",
"CODE",
"SERVER",
}
const createMutation = `
mutation($input: CreateCompliancePortalCommitmentInput!) {
createCompliancePortalCommitment(input: $input) {
compliancePortalCommitmentEdge {
node {
id
icon
eyebrow
title
description
rank
}
}
}
}
`
type createResponse struct {
CreateCompliancePortalCommitment struct {
CompliancePortalCommitmentEdge struct {
Node struct {
ID string `json:"id"`
Icon string `json:"icon"`
Eyebrow string `json:"eyebrow"`
Title string `json:"title"`
Description string `json:"description"`
Rank int `json:"rank"`
} `json:"node"`
} `json:"compliancePortalCommitmentEdge"`
} `json:"createCompliancePortalCommitment"`
}
func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
var (
flagGroup string
flagIcon string
flagEyebrow string
flagTitle string
flagDescription string
)
cmd := &cobra.Command{
Use: "create",
Short: "Create a compliance portal commitment",
Example: ` # Create a commitment interactively
prb trust-center commitment create --group <group-id>
# Create a commitment non-interactively
prb trust-center cmt create --group <group-id> --icon SHIELD_CHECK --eyebrow "Security" --title "Encryption" --description "Data encrypted at rest"`,
RunE: func(cmd *cobra.Command, args []string) error {
cfg, err := f.Config()
if err != nil {
return err
}
host, hc, err := cfg.DefaultHost()
if err != nil {
return err
}
client := api.NewClient(
host,
hc.Token,
"/api/console/v1/graphql",
cfg.HTTPTimeoutDuration(),
cmdutil.TokenRefreshOption(cfg, host, hc),
)
if f.IOStreams.IsInteractive() {
if flagGroup == "" {
err := huh.NewInput().
Title("Commitment group ID").
Value(&flagGroup).
Run()
if err != nil {
return err
}
}
if flagIcon == "" {
iconOptions := make([]huh.Option[string], 0, len(validIcons))
for _, icon := range validIcons {
iconOptions = append(iconOptions, huh.NewOption(icon, icon))
}
err := huh.NewSelect[string]().
Title("Icon").
Options(iconOptions...).
Value(&flagIcon).
Run()
if err != nil {
return err
}
}
if flagEyebrow == "" {
err := huh.NewInput().
Title("Eyebrow").
Value(&flagEyebrow).
Run()
if err != nil {
return err
}
}
if flagTitle == "" {
err := huh.NewInput().
Title("Title").
Value(&flagTitle).
Run()
if err != nil {
return err
}
}
if flagDescription == "" {
err := huh.NewText().
Title("Description").
Value(&flagDescription).
Run()
if err != nil {
return err
}
}
}
if flagGroup == "" {
return fmt.Errorf("group is required; pass --group or run interactively")
}
if flagIcon == "" {
return fmt.Errorf("icon is required; pass --icon or run interactively")
}
if err := cmdutil.ValidateEnum("icon", flagIcon, validIcons); err != nil {
return err
}
if flagEyebrow == "" {
return fmt.Errorf("eyebrow is required; pass --eyebrow or run interactively")
}
if flagTitle == "" {
return fmt.Errorf("title is required; pass --title or run interactively")
}
if flagDescription == "" {
return fmt.Errorf("description is required; pass --description or run interactively")
}
data, err := client.Do(
createMutation,
map[string]any{
"input": map[string]any{
"groupId": flagGroup,
"icon": flagIcon,
"eyebrow": flagEyebrow,
"title": flagTitle,
"description": flagDescription,
},
},
)
if err != nil {
return err
}
var resp createResponse
if err := json.Unmarshal(data, &resp); err != nil {
return fmt.Errorf("cannot parse response: %w", err)
}
c := resp.CreateCompliancePortalCommitment.CompliancePortalCommitmentEdge.Node
_, _ = fmt.Fprintf(
f.IOStreams.Out,
"Created commitment %s (%s)\n",
c.ID,
c.Title,
)
return nil
},
}
cmd.Flags().StringVar(&flagGroup, "group", "", "Commitment group ID (required)")
cmd.Flags().StringVar(&flagIcon, "icon", "", "Commitment icon (required)")
cmd.Flags().StringVar(&flagEyebrow, "eyebrow", "", "Commitment eyebrow (required)")
cmd.Flags().StringVar(&flagTitle, "title", "", "Commitment title (required)")
cmd.Flags().StringVar(&flagDescription, "description", "", "Commitment description (required)")
return cmd
}

View File

@@ -0,0 +1,111 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package delete
import (
"fmt"
"github.com/charmbracelet/huh"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
)
const deleteMutation = `
mutation($input: DeleteCompliancePortalCommitmentInput!) {
deleteCompliancePortalCommitment(input: $input) {
deletedCompliancePortalCommitmentId
}
}
`
func NewCmdDelete(f *cmdutil.Factory) *cobra.Command {
var flagYes bool
cmd := &cobra.Command{
Use: "delete <id>",
Short: "Delete a compliance portal commitment",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if !flagYes {
if !f.IOStreams.IsInteractive() {
return fmt.Errorf("cannot delete commitment: confirmation required, use --yes to confirm")
}
var confirmed bool
err := huh.NewConfirm().
Title(fmt.Sprintf("Delete commitment %s?", args[0])).
Value(&confirmed).
Run()
if err != nil {
return err
}
if !confirmed {
return nil
}
}
cfg, err := f.Config()
if err != nil {
return err
}
host, hc, err := cfg.DefaultHost()
if err != nil {
return err
}
client := api.NewClient(
host,
hc.Token,
"/api/console/v1/graphql",
cfg.HTTPTimeoutDuration(),
cmdutil.TokenRefreshOption(cfg, host, hc),
)
_, err = client.Do(
deleteMutation,
map[string]any{
"input": map[string]any{
"id": args[0],
},
},
)
if err != nil {
return err
}
_, _ = fmt.Fprintf(
f.IOStreams.Out,
"Deleted commitment %s\n",
args[0],
)
return nil
},
}
cmd.Flags().BoolVarP(&flagYes, "yes", "y", false, "Skip confirmation prompt")
return cmd
}

View File

@@ -0,0 +1,206 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package list
import (
"encoding/json"
"fmt"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
)
const listQuery = `
query($id: ID!, $first: Int, $after: CursorKey, $orderBy: CompliancePortalCommitmentOrder) {
node(id: $id) {
__typename
... on CompliancePortalCommitmentGroup {
commitments(first: $first, after: $after, orderBy: $orderBy) {
totalCount
edges {
node {
id
icon
eyebrow
title
description
rank
createdAt
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
}
`
type commitment struct {
ID string `json:"id"`
Icon string `json:"icon"`
Eyebrow string `json:"eyebrow"`
Title string `json:"title"`
Description string `json:"description"`
Rank int `json:"rank"`
CreatedAt string `json:"createdAt"`
}
func NewCmdList(f *cmdutil.Factory) *cobra.Command {
var (
flagGroup string
flagLimit int
flagOrderBy string
flagOrderDir string
flagOutput *string
)
cmd := &cobra.Command{
Use: "list",
Short: "List compliance portal commitments",
Aliases: []string{"ls"},
Example: ` # List commitments in a group
prb trust-center commitment list --group <group-id>
# List commitments sorted by rank
prb trust-center cmt ls --group <group-id> --order-by RANK`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if err := cmdutil.ValidateOutputFlag(flagOutput); err != nil {
return err
}
if flagGroup == "" {
return fmt.Errorf("group is required; pass --group")
}
cfg, err := f.Config()
if err != nil {
return err
}
host, hc, err := cfg.DefaultHost()
if err != nil {
return err
}
client := api.NewClient(
host,
hc.Token,
"/api/console/v1/graphql",
cfg.HTTPTimeoutDuration(),
cmdutil.TokenRefreshOption(cfg, host, hc),
)
variables := map[string]any{
"id": flagGroup,
}
if flagOrderBy != "" {
if err := cmdutil.ValidateEnum("order-by", flagOrderBy, []string{"RANK", "CREATED_AT", "UPDATED_AT"}); err != nil {
return err
}
variables["orderBy"] = map[string]any{
"field": flagOrderBy,
"direction": flagOrderDir,
}
}
commitments, totalCount, err := api.Paginate(
client,
listQuery,
variables,
flagLimit,
func(data json.RawMessage) (*api.Connection[commitment], error) {
var resp struct {
Node *struct {
Typename string `json:"__typename"`
Commitments api.Connection[commitment] `json:"commitments"`
} `json:"node"`
}
if err := json.Unmarshal(data, &resp); err != nil {
return nil, err
}
if resp.Node == nil {
return nil, fmt.Errorf("commitment group %s not found", flagGroup)
}
if resp.Node.Typename != "CompliancePortalCommitmentGroup" {
return nil, fmt.Errorf("expected CompliancePortalCommitmentGroup node, got %s", resp.Node.Typename)
}
return &resp.Node.Commitments, nil
},
)
if err != nil {
return err
}
if *flagOutput == cmdutil.OutputJSON {
return cmdutil.PrintJSON(f.IOStreams.Out, commitments)
}
if len(commitments) == 0 {
_, _ = fmt.Fprintln(f.IOStreams.Out, "No commitments found.")
return nil
}
rows := make([][]string, 0, len(commitments))
for _, c := range commitments {
rows = append(rows, []string{
c.ID,
c.Icon,
c.Eyebrow,
c.Title,
fmt.Sprintf("%d", c.Rank),
})
}
t := cmdutil.NewTable("ID", "ICON", "EYEBROW", "TITLE", "RANK").Rows(rows...)
_, _ = fmt.Fprintln(f.IOStreams.Out, t)
if totalCount > len(commitments) {
_, _ = fmt.Fprintf(
f.IOStreams.ErrOut,
"\nShowing %d of %d commitments\n",
len(commitments),
totalCount,
)
}
return nil
},
}
cmd.Flags().StringVar(&flagGroup, "group", "", "Commitment group ID (required)")
cmd.Flags().IntVarP(&flagLimit, "limit", "L", 30, "Maximum number of commitments to list")
cmd.Flags().StringVar(&flagOrderBy, "order-by", "", "Order by field (RANK, CREATED_AT, UPDATED_AT)")
cmd.Flags().StringVar(&flagOrderDir, "order-direction", "DESC", "Sort direction (ASC, DESC)")
flagOutput = cmdutil.AddOutputFlag(cmd)
return cmd
}

View File

@@ -0,0 +1,184 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package update
import (
"encoding/json"
"fmt"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
)
var validIcons = []string{
"LOCK_KEY",
"EYE_SLASH",
"FINGERPRINT",
"SHIELD_WARNING",
"SHIELD_CHECK",
"SIREN",
"KEY",
"LOCK",
"CLOUD",
"DATABASE",
"GLOBE",
"EYE",
"USERS",
"CERTIFICATE",
"GAVEL",
"HEARTBEAT",
"BELL",
"BUG",
"CODE",
"SERVER",
}
const updateMutation = `
mutation($input: UpdateCompliancePortalCommitmentInput!) {
updateCompliancePortalCommitment(input: $input) {
compliancePortalCommitment {
id
icon
eyebrow
title
description
rank
}
}
}
`
type updateResponse struct {
UpdateCompliancePortalCommitment struct {
CompliancePortalCommitment struct {
ID string `json:"id"`
Icon string `json:"icon"`
Eyebrow string `json:"eyebrow"`
Title string `json:"title"`
Description string `json:"description"`
Rank int `json:"rank"`
} `json:"compliancePortalCommitment"`
} `json:"updateCompliancePortalCommitment"`
}
func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
var (
flagIcon string
flagEyebrow string
flagTitle string
flagDescription string
flagRank int
)
cmd := &cobra.Command{
Use: "update <id>",
Short: "Update a compliance portal commitment",
Example: ` # Update a commitment title
prb trust-center commitment update <id> --title "Encryption at rest"
# Update icon and rank
prb trust-center cmt update <id> --icon SHIELD_CHECK --rank 1`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
cfg, err := f.Config()
if err != nil {
return err
}
host, hc, err := cfg.DefaultHost()
if err != nil {
return err
}
client := api.NewClient(
host,
hc.Token,
"/api/console/v1/graphql",
cfg.HTTPTimeoutDuration(),
cmdutil.TokenRefreshOption(cfg, host, hc),
)
input := map[string]any{
"id": args[0],
}
if cmd.Flags().Changed("icon") {
if err := cmdutil.ValidateEnum("icon", flagIcon, validIcons); err != nil {
return err
}
input["icon"] = flagIcon
}
if cmd.Flags().Changed("eyebrow") {
input["eyebrow"] = flagEyebrow
}
if cmd.Flags().Changed("title") {
input["title"] = flagTitle
}
if cmd.Flags().Changed("description") {
input["description"] = flagDescription
}
if cmd.Flags().Changed("rank") {
input["rank"] = flagRank
}
if len(input) == 1 {
return fmt.Errorf("at least one field must be specified for update")
}
data, err := client.Do(
updateMutation,
map[string]any{"input": input},
)
if err != nil {
return err
}
var resp updateResponse
if err := json.Unmarshal(data, &resp); err != nil {
return fmt.Errorf("cannot parse response: %w", err)
}
c := resp.UpdateCompliancePortalCommitment.CompliancePortalCommitment
_, _ = fmt.Fprintf(
f.IOStreams.Out,
"Updated commitment %s (%s)\n",
c.ID,
c.Title,
)
return nil
},
}
cmd.Flags().StringVar(&flagIcon, "icon", "", "Commitment icon")
cmd.Flags().StringVar(&flagEyebrow, "eyebrow", "", "Commitment eyebrow")
cmd.Flags().StringVar(&flagTitle, "title", "", "Commitment title")
cmd.Flags().StringVar(&flagDescription, "description", "", "Commitment description")
cmd.Flags().IntVar(&flagRank, "rank", 0, "Display rank")
return cmd
}

View File

@@ -0,0 +1,45 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package commitmentgroup
import (
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cmd/cmdutil"
"go.probo.inc/probo/pkg/cmd/compliance-portal/commitmentgroup/create"
"go.probo.inc/probo/pkg/cmd/compliance-portal/commitmentgroup/delete"
"go.probo.inc/probo/pkg/cmd/compliance-portal/commitmentgroup/list"
"go.probo.inc/probo/pkg/cmd/compliance-portal/commitmentgroup/update"
)
func NewCmdCommitmentGroup(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "commitment-group <command>",
Short: "Manage compliance portal commitment groups",
Aliases: []string{"cg"},
}
cmd.AddCommand(list.NewCmdList(f))
cmd.AddCommand(create.NewCmdCreate(f))
cmd.AddCommand(update.NewCmdUpdate(f))
cmd.AddCommand(delete.NewCmdDelete(f))
return cmd
}

View File

@@ -0,0 +1,216 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package create
import (
"encoding/json"
"fmt"
"github.com/charmbracelet/huh"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
)
const trustCenterQuery = `
query($id: ID!) {
node(id: $id) {
__typename
... on Organization {
trustCenter {
id
}
}
}
}
`
const createMutation = `
mutation($input: CreateCompliancePortalCommitmentGroupInput!) {
createCompliancePortalCommitmentGroup(input: $input) {
compliancePortalCommitmentGroupEdge {
node {
id
title
description
rank
}
}
}
}
`
type trustCenterQueryResponse struct {
Node *struct {
Typename string `json:"__typename"`
TrustCenter *struct {
ID string `json:"id"`
} `json:"trustCenter"`
} `json:"node"`
}
type createResponse struct {
CreateCompliancePortalCommitmentGroup struct {
CompliancePortalCommitmentGroupEdge struct {
Node struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
Rank int `json:"rank"`
} `json:"node"`
} `json:"compliancePortalCommitmentGroupEdge"`
} `json:"createCompliancePortalCommitmentGroup"`
}
func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
var (
flagOrg string
flagTitle string
flagDescription string
)
cmd := &cobra.Command{
Use: "create",
Short: "Create a compliance portal commitment group",
Example: ` # Create a commitment group interactively
prb trust-center commitment-group create
# Create a commitment group non-interactively
prb trust-center cg create --title "Security" --description "Our security commitments"`,
RunE: func(cmd *cobra.Command, args []string) error {
cfg, err := f.Config()
if err != nil {
return err
}
host, hc, err := cfg.DefaultHost()
if err != nil {
return err
}
client := api.NewClient(
host,
hc.Token,
"/api/console/v1/graphql",
cfg.HTTPTimeoutDuration(),
cmdutil.TokenRefreshOption(cfg, host, hc),
)
if flagOrg == "" {
flagOrg = hc.Organization
}
if flagOrg == "" {
return fmt.Errorf("organization is required; pass --org or set a default with 'prb auth login'")
}
data, err := client.Do(
trustCenterQuery,
map[string]any{"id": flagOrg},
)
if err != nil {
return err
}
var tcResp trustCenterQueryResponse
if err := json.Unmarshal(data, &tcResp); err != nil {
return fmt.Errorf("cannot parse response: %w", err)
}
if tcResp.Node == nil {
return fmt.Errorf("organization %s not found", flagOrg)
}
if tcResp.Node.Typename != "Organization" {
return fmt.Errorf("expected Organization node, got %s", tcResp.Node.Typename)
}
if tcResp.Node.TrustCenter == nil {
return fmt.Errorf("trust center not found for organization %s", flagOrg)
}
if f.IOStreams.IsInteractive() {
if flagTitle == "" {
err := huh.NewInput().
Title("Group title").
Value(&flagTitle).
Run()
if err != nil {
return err
}
}
if flagDescription == "" {
err := huh.NewText().
Title("Description").
Value(&flagDescription).
Run()
if err != nil {
return err
}
}
}
if flagTitle == "" {
return fmt.Errorf("title is required; pass --title or run interactively")
}
if flagDescription == "" {
return fmt.Errorf("description is required; pass --description or run interactively")
}
data, err = client.Do(
createMutation,
map[string]any{
"input": map[string]any{
"trustCenterId": tcResp.Node.TrustCenter.ID,
"title": flagTitle,
"description": flagDescription,
},
},
)
if err != nil {
return err
}
var resp createResponse
if err := json.Unmarshal(data, &resp); err != nil {
return fmt.Errorf("cannot parse response: %w", err)
}
g := resp.CreateCompliancePortalCommitmentGroup.CompliancePortalCommitmentGroupEdge.Node
_, _ = fmt.Fprintf(
f.IOStreams.Out,
"Created commitment group %s (%s)\n",
g.ID,
g.Title,
)
return nil
},
}
cmd.Flags().StringVar(&flagOrg, "org", "", "Organization ID")
cmd.Flags().StringVar(&flagTitle, "title", "", "Group title (required)")
cmd.Flags().StringVar(&flagDescription, "description", "", "Group description (required)")
return cmd
}

View File

@@ -0,0 +1,111 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package delete
import (
"fmt"
"github.com/charmbracelet/huh"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
)
const deleteMutation = `
mutation($input: DeleteCompliancePortalCommitmentGroupInput!) {
deleteCompliancePortalCommitmentGroup(input: $input) {
deletedCompliancePortalCommitmentGroupId
}
}
`
func NewCmdDelete(f *cmdutil.Factory) *cobra.Command {
var flagYes bool
cmd := &cobra.Command{
Use: "delete <id>",
Short: "Delete a compliance portal commitment group",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if !flagYes {
if !f.IOStreams.IsInteractive() {
return fmt.Errorf("cannot delete commitment group: confirmation required, use --yes to confirm")
}
var confirmed bool
err := huh.NewConfirm().
Title(fmt.Sprintf("Delete commitment group %s?", args[0])).
Value(&confirmed).
Run()
if err != nil {
return err
}
if !confirmed {
return nil
}
}
cfg, err := f.Config()
if err != nil {
return err
}
host, hc, err := cfg.DefaultHost()
if err != nil {
return err
}
client := api.NewClient(
host,
hc.Token,
"/api/console/v1/graphql",
cfg.HTTPTimeoutDuration(),
cmdutil.TokenRefreshOption(cfg, host, hc),
)
_, err = client.Do(
deleteMutation,
map[string]any{
"input": map[string]any{
"id": args[0],
},
},
)
if err != nil {
return err
}
_, _ = fmt.Fprintf(
f.IOStreams.Out,
"Deleted commitment group %s\n",
args[0],
)
return nil
},
}
cmd.Flags().BoolVarP(&flagYes, "yes", "y", false, "Skip confirmation prompt")
return cmd
}

View File

@@ -0,0 +1,212 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package list
import (
"encoding/json"
"fmt"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
)
const listQuery = `
query($id: ID!, $first: Int, $after: CursorKey, $orderBy: CompliancePortalCommitmentGroupOrder) {
node(id: $id) {
__typename
... on Organization {
trustCenter {
commitmentGroups(first: $first, after: $after, orderBy: $orderBy) {
totalCount
edges {
node {
id
title
description
rank
createdAt
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
}
}
`
type commitmentGroup struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
Rank int `json:"rank"`
CreatedAt string `json:"createdAt"`
}
func NewCmdList(f *cmdutil.Factory) *cobra.Command {
var (
flagOrg string
flagLimit int
flagOrderBy string
flagOrderDir string
flagOutput *string
)
cmd := &cobra.Command{
Use: "list",
Short: "List compliance portal commitment groups",
Aliases: []string{"ls"},
Example: ` # List commitment groups in the default organization
prb trust-center commitment-group list
# List commitment groups sorted by rank
prb trust-center cg ls --order-by RANK`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if err := cmdutil.ValidateOutputFlag(flagOutput); err != nil {
return err
}
cfg, err := f.Config()
if err != nil {
return err
}
host, hc, err := cfg.DefaultHost()
if err != nil {
return err
}
client := api.NewClient(
host,
hc.Token,
"/api/console/v1/graphql",
cfg.HTTPTimeoutDuration(),
cmdutil.TokenRefreshOption(cfg, host, hc),
)
if flagOrg == "" {
flagOrg = hc.Organization
}
if flagOrg == "" {
return fmt.Errorf("organization is required; pass --org or set a default with 'prb auth login'")
}
variables := map[string]any{
"id": flagOrg,
}
if flagOrderBy != "" {
if err := cmdutil.ValidateEnum("order-by", flagOrderBy, []string{"RANK", "CREATED_AT", "UPDATED_AT"}); err != nil {
return err
}
variables["orderBy"] = map[string]any{
"field": flagOrderBy,
"direction": flagOrderDir,
}
}
groups, totalCount, err := api.Paginate(
client,
listQuery,
variables,
flagLimit,
func(data json.RawMessage) (*api.Connection[commitmentGroup], error) {
var resp struct {
Node *struct {
Typename string `json:"__typename"`
TrustCenter *struct {
CommitmentGroups api.Connection[commitmentGroup] `json:"commitmentGroups"`
} `json:"trustCenter"`
} `json:"node"`
}
if err := json.Unmarshal(data, &resp); err != nil {
return nil, err
}
if resp.Node == nil {
return nil, fmt.Errorf("organization %s not found", flagOrg)
}
if resp.Node.Typename != "Organization" {
return nil, fmt.Errorf("expected Organization node, got %s", resp.Node.Typename)
}
if resp.Node.TrustCenter == nil {
return nil, fmt.Errorf("trust center not found for organization %s", flagOrg)
}
return &resp.Node.TrustCenter.CommitmentGroups, nil
},
)
if err != nil {
return err
}
if *flagOutput == cmdutil.OutputJSON {
return cmdutil.PrintJSON(f.IOStreams.Out, groups)
}
if len(groups) == 0 {
_, _ = fmt.Fprintln(f.IOStreams.Out, "No commitment groups found.")
return nil
}
rows := make([][]string, 0, len(groups))
for _, g := range groups {
rows = append(rows, []string{
g.ID,
g.Title,
fmt.Sprintf("%d", g.Rank),
})
}
t := cmdutil.NewTable("ID", "TITLE", "RANK").Rows(rows...)
_, _ = fmt.Fprintln(f.IOStreams.Out, t)
if totalCount > len(groups) {
_, _ = fmt.Fprintf(
f.IOStreams.ErrOut,
"\nShowing %d of %d commitment groups\n",
len(groups),
totalCount,
)
}
return nil
},
}
cmd.Flags().StringVar(&flagOrg, "org", "", "Organization ID")
cmd.Flags().IntVarP(&flagLimit, "limit", "L", 30, "Maximum number of commitment groups to list")
cmd.Flags().StringVar(&flagOrderBy, "order-by", "", "Order by field (RANK, CREATED_AT, UPDATED_AT)")
cmd.Flags().StringVar(&flagOrderDir, "order-direction", "DESC", "Sort direction (ASC, DESC)")
flagOutput = cmdutil.AddOutputFlag(cmd)
return cmd
}

View File

@@ -0,0 +1,141 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package update
import (
"encoding/json"
"fmt"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
)
const updateMutation = `
mutation($input: UpdateCompliancePortalCommitmentGroupInput!) {
updateCompliancePortalCommitmentGroup(input: $input) {
compliancePortalCommitmentGroup {
id
title
description
rank
}
}
}
`
type updateResponse struct {
UpdateCompliancePortalCommitmentGroup struct {
CompliancePortalCommitmentGroup struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
Rank int `json:"rank"`
} `json:"compliancePortalCommitmentGroup"`
} `json:"updateCompliancePortalCommitmentGroup"`
}
func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
var (
flagTitle string
flagDescription string
flagRank int
)
cmd := &cobra.Command{
Use: "update <id>",
Short: "Update a compliance portal commitment group",
Example: ` # Update a commitment group title
prb trust-center commitment-group update <id> --title "Privacy"
# Update rank
prb trust-center cg update <id> --rank 2`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
cfg, err := f.Config()
if err != nil {
return err
}
host, hc, err := cfg.DefaultHost()
if err != nil {
return err
}
client := api.NewClient(
host,
hc.Token,
"/api/console/v1/graphql",
cfg.HTTPTimeoutDuration(),
cmdutil.TokenRefreshOption(cfg, host, hc),
)
input := map[string]any{
"id": args[0],
}
if cmd.Flags().Changed("title") {
input["title"] = flagTitle
}
if cmd.Flags().Changed("description") {
input["description"] = flagDescription
}
if cmd.Flags().Changed("rank") {
input["rank"] = flagRank
}
if len(input) == 1 {
return fmt.Errorf("at least one field must be specified for update")
}
data, err := client.Do(
updateMutation,
map[string]any{"input": input},
)
if err != nil {
return err
}
var resp updateResponse
if err := json.Unmarshal(data, &resp); err != nil {
return fmt.Errorf("cannot parse response: %w", err)
}
g := resp.UpdateCompliancePortalCommitmentGroup.CompliancePortalCommitmentGroup
_, _ = fmt.Fprintf(
f.IOStreams.Out,
"Updated commitment group %s (%s)\n",
g.ID,
g.Title,
)
return nil
},
}
cmd.Flags().StringVar(&flagTitle, "title", "", "Group title")
cmd.Flags().StringVar(&flagDescription, "description", "", "Group description")
cmd.Flags().IntVar(&flagRank, "rank", 0, "Display rank")
return cmd
}

View File

@@ -0,0 +1,49 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package complianceportal
import (
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cmd/cmdutil"
"go.probo.inc/probo/pkg/cmd/compliance-portal/commitment"
"go.probo.inc/probo/pkg/cmd/compliance-portal/commitmentgroup"
"go.probo.inc/probo/pkg/cmd/compliance-portal/file"
"go.probo.inc/probo/pkg/cmd/compliance-portal/reference"
"go.probo.inc/probo/pkg/cmd/compliance-portal/update"
"go.probo.inc/probo/pkg/cmd/compliance-portal/view"
)
func NewCmdCompliancePortal(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "compliance-portal <command>",
Short: "Manage compliance portal",
Aliases: []string{"tc"},
}
cmd.AddCommand(view.NewCmdView(f))
cmd.AddCommand(update.NewCmdUpdate(f))
cmd.AddCommand(reference.NewCmdReference(f))
cmd.AddCommand(commitmentgroup.NewCmdCommitmentGroup(f))
cmd.AddCommand(commitment.NewCmdCommitment(f))
cmd.AddCommand(file.NewCmdFile(f))
return cmd
}

View File

@@ -0,0 +1,111 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package delete
import (
"fmt"
"github.com/charmbracelet/huh"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
)
const deleteMutation = `
mutation($input: DeleteCompliancePortalFileInput!) {
deleteCompliancePortalFile(input: $input) {
deletedCompliancePortalFileId
}
}
`
func NewCmdDelete(f *cmdutil.Factory) *cobra.Command {
var flagYes bool
cmd := &cobra.Command{
Use: "delete <id>",
Short: "Delete a compliance portal file",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if !flagYes {
if !f.IOStreams.IsInteractive() {
return fmt.Errorf("cannot delete file: confirmation required, use --yes to confirm")
}
var confirmed bool
err := huh.NewConfirm().
Title(fmt.Sprintf("Delete compliance portal file %s?", args[0])).
Value(&confirmed).
Run()
if err != nil {
return err
}
if !confirmed {
return nil
}
}
cfg, err := f.Config()
if err != nil {
return err
}
host, hc, err := cfg.DefaultHost()
if err != nil {
return err
}
client := api.NewClient(
host,
hc.Token,
"/api/console/v1/graphql",
cfg.HTTPTimeoutDuration(),
cmdutil.TokenRefreshOption(cfg, host, hc),
)
_, err = client.Do(
deleteMutation,
map[string]any{
"input": map[string]any{
"id": args[0],
},
},
)
if err != nil {
return err
}
_, _ = fmt.Fprintf(
f.IOStreams.Out,
"Deleted compliance portal file %s\n",
args[0],
)
return nil
},
}
cmd.Flags().BoolVarP(&flagYes, "yes", "y", false, "Skip confirmation prompt")
return cmd
}

View File

@@ -0,0 +1,40 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package file
import (
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cmd/cmdutil"
"go.probo.inc/probo/pkg/cmd/compliance-portal/file/delete"
"go.probo.inc/probo/pkg/cmd/compliance-portal/file/list"
)
func NewCmdFile(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "file <command>",
Short: "Manage compliance portal files",
}
cmd.AddCommand(list.NewCmdList(f))
cmd.AddCommand(delete.NewCmdDelete(f))
return cmd
}

View File

@@ -0,0 +1,205 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package list
import (
"encoding/json"
"fmt"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
)
const listQuery = `
query($id: ID!, $first: Int, $after: CursorKey, $orderBy: CompliancePortalFileOrder) {
node(id: $id) {
__typename
... on Organization {
compliancePortalFiles(first: $first, after: $after, orderBy: $orderBy) {
totalCount
edges {
node {
id
name
category
compliancePortalVisibility
createdAt
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
}
`
type compliancePortalFile struct {
ID string `json:"id"`
Name string `json:"name"`
Category string `json:"category"`
CompliancePortalVisibility string `json:"compliancePortalVisibility"`
CreatedAt string `json:"createdAt"`
}
func NewCmdList(f *cmdutil.Factory) *cobra.Command {
var (
flagOrg string
flagLimit int
flagOrderBy string
flagOrderDir string
flagOutput *string
)
cmd := &cobra.Command{
Use: "list",
Short: "List compliance portal files",
Aliases: []string{"ls"},
Example: ` # List files in the default organization
prb compliance-portal file list
# List files sorted by name
prb compliance-portal file ls --order-by NAME`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if err := cmdutil.ValidateOutputFlag(flagOutput); err != nil {
return err
}
cfg, err := f.Config()
if err != nil {
return err
}
host, hc, err := cfg.DefaultHost()
if err != nil {
return err
}
client := api.NewClient(
host,
hc.Token,
"/api/console/v1/graphql",
cfg.HTTPTimeoutDuration(),
cmdutil.TokenRefreshOption(cfg, host, hc),
)
if flagOrg == "" {
flagOrg = hc.Organization
}
if flagOrg == "" {
return fmt.Errorf("organization is required; pass --org or set a default with 'prb auth login'")
}
variables := map[string]any{
"id": flagOrg,
}
if flagOrderBy != "" {
if err := cmdutil.ValidateEnum("order-by", flagOrderBy, []string{"NAME", "CREATED_AT", "UPDATED_AT"}); err != nil {
return err
}
variables["orderBy"] = map[string]any{
"field": flagOrderBy,
"direction": flagOrderDir,
}
}
files, totalCount, err := api.Paginate(
client,
listQuery,
variables,
flagLimit,
func(data json.RawMessage) (*api.Connection[compliancePortalFile], error) {
var resp struct {
Node *struct {
Typename string `json:"__typename"`
CompliancePortalFiles api.Connection[compliancePortalFile] `json:"compliancePortalFiles"`
} `json:"node"`
}
if err := json.Unmarshal(data, &resp); err != nil {
return nil, err
}
if resp.Node == nil {
return nil, fmt.Errorf("organization %s not found", flagOrg)
}
if resp.Node.Typename != "Organization" {
return nil, fmt.Errorf("expected Organization node, got %s", resp.Node.Typename)
}
return &resp.Node.CompliancePortalFiles, nil
},
)
if err != nil {
return err
}
if *flagOutput == cmdutil.OutputJSON {
return cmdutil.PrintJSON(f.IOStreams.Out, files)
}
if len(files) == 0 {
_, _ = fmt.Fprintln(f.IOStreams.Out, "No files found.")
return nil
}
rows := make([][]string, 0, len(files))
for _, file := range files {
rows = append(rows, []string{
file.ID,
file.Name,
file.Category,
file.CompliancePortalVisibility,
})
}
t := cmdutil.NewTable("ID", "NAME", "CATEGORY", "VISIBILITY").Rows(rows...)
_, _ = fmt.Fprintln(f.IOStreams.Out, t)
if totalCount > len(files) {
_, _ = fmt.Fprintf(
f.IOStreams.ErrOut,
"\nShowing %d of %d files\n",
len(files),
totalCount,
)
}
return nil
},
}
cmd.Flags().StringVar(&flagOrg, "org", "", "Organization ID")
cmd.Flags().IntVarP(&flagLimit, "limit", "L", 30, "Maximum number of files to list")
cmd.Flags().StringVar(&flagOrderBy, "order-by", "", "Order by field (NAME, CREATED_AT, UPDATED_AT)")
cmd.Flags().StringVar(&flagOrderDir, "order-direction", "DESC", "Sort direction (ASC, DESC)")
flagOutput = cmdutil.AddOutputFlag(cmd)
return cmd
}

View File

@@ -0,0 +1,234 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package create
import (
"encoding/json"
"fmt"
"github.com/charmbracelet/huh"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
)
const compliancePortalQuery = `
query($id: ID!) {
node(id: $id) {
__typename
... on Organization {
compliancePortal {
id
}
}
}
}
`
const createMutation = `
mutation($input: CreateCompliancePortalReferenceInput!) {
createCompliancePortalReference(input: $input) {
compliancePortalReferenceEdge {
node {
id
name
description
websiteUrl
rank
}
}
}
}
`
type compliancePortalQueryResponse struct {
Node *struct {
Typename string `json:"__typename"`
CompliancePortal *struct {
ID string `json:"id"`
} `json:"compliancePortal"`
} `json:"node"`
}
type createResponse struct {
CreateCompliancePortalReference struct {
CompliancePortalReferenceEdge struct {
Node struct {
ID string `json:"id"`
Name string `json:"name"`
Description *string `json:"description"`
WebsiteUrl *string `json:"websiteUrl"`
Rank int `json:"rank"`
} `json:"node"`
} `json:"compliancePortalReferenceEdge"`
} `json:"createCompliancePortalReference"`
}
func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
var (
flagOrg string
flagName string
flagDescription string
flagWebsite string
)
cmd := &cobra.Command{
Use: "create",
Short: "Create a compliance portal reference",
Example: ` # Create a reference interactively
prb compliance-portal reference create
# Create a reference non-interactively
prb compliance-portal ref create --name "Acme Corp" --description "Enterprise customer" --website "https://acme.com"`,
RunE: func(cmd *cobra.Command, args []string) error {
cfg, err := f.Config()
if err != nil {
return err
}
host, hc, err := cfg.DefaultHost()
if err != nil {
return err
}
client := api.NewClient(
host,
hc.Token,
"/api/console/v1/graphql",
cfg.HTTPTimeoutDuration(),
cmdutil.TokenRefreshOption(cfg, host, hc),
)
if flagOrg == "" {
flagOrg = hc.Organization
}
if flagOrg == "" {
return fmt.Errorf("organization is required; pass --org or set a default with 'prb auth login'")
}
// Fetch compliance portal ID from organization.
data, err := client.Do(
compliancePortalQuery,
map[string]any{"id": flagOrg},
)
if err != nil {
return err
}
var tcResp compliancePortalQueryResponse
if err := json.Unmarshal(data, &tcResp); err != nil {
return fmt.Errorf("cannot parse response: %w", err)
}
if tcResp.Node == nil {
return fmt.Errorf("organization %s not found", flagOrg)
}
if tcResp.Node.Typename != "Organization" {
return fmt.Errorf("expected Organization node, got %s", tcResp.Node.Typename)
}
if tcResp.Node.CompliancePortal == nil {
return fmt.Errorf("compliance portal not found for organization %s", flagOrg)
}
if f.IOStreams.IsInteractive() {
if flagName == "" {
err := huh.NewInput().
Title("Reference name").
Value(&flagName).
Run()
if err != nil {
return err
}
}
if flagDescription == "" {
err := huh.NewInput().
Title("Description (optional)").
Value(&flagDescription).
Run()
if err != nil {
return err
}
}
if flagWebsite == "" {
err := huh.NewInput().
Title("Website URL (optional)").
Value(&flagWebsite).
Run()
if err != nil {
return err
}
}
}
if flagName == "" {
return fmt.Errorf("name is required; pass --name or run interactively")
}
input := map[string]any{
"compliancePortalId": tcResp.Node.CompliancePortal.ID,
"name": flagName,
}
if flagDescription != "" {
input["description"] = flagDescription
}
if flagWebsite != "" {
input["websiteUrl"] = flagWebsite
}
data, err = client.Do(
createMutation,
map[string]any{"input": input},
)
if err != nil {
return err
}
var resp createResponse
if err := json.Unmarshal(data, &resp); err != nil {
return fmt.Errorf("cannot parse response: %w", err)
}
r := resp.CreateCompliancePortalReference.CompliancePortalReferenceEdge.Node
_, _ = fmt.Fprintf(
f.IOStreams.Out,
"Created reference %s (%s)\n",
r.ID,
r.Name,
)
return nil
},
}
cmd.Flags().StringVar(&flagOrg, "org", "", "Organization ID")
cmd.Flags().StringVar(&flagName, "name", "", "Reference name (required)")
cmd.Flags().StringVar(&flagDescription, "description", "", "Reference description")
cmd.Flags().StringVar(&flagWebsite, "website", "", "Website URL")
return cmd
}

View File

@@ -0,0 +1,111 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package delete
import (
"fmt"
"github.com/charmbracelet/huh"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
)
const deleteMutation = `
mutation($input: DeleteCompliancePortalReferenceInput!) {
deleteCompliancePortalReference(input: $input) {
deletedCompliancePortalReferenceId
}
}
`
func NewCmdDelete(f *cmdutil.Factory) *cobra.Command {
var flagYes bool
cmd := &cobra.Command{
Use: "delete <id>",
Short: "Delete a compliance portal reference",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if !flagYes {
if !f.IOStreams.IsInteractive() {
return fmt.Errorf("cannot delete reference: confirmation required, use --yes to confirm")
}
var confirmed bool
err := huh.NewConfirm().
Title(fmt.Sprintf("Delete reference %s?", args[0])).
Value(&confirmed).
Run()
if err != nil {
return err
}
if !confirmed {
return nil
}
}
cfg, err := f.Config()
if err != nil {
return err
}
host, hc, err := cfg.DefaultHost()
if err != nil {
return err
}
client := api.NewClient(
host,
hc.Token,
"/api/console/v1/graphql",
cfg.HTTPTimeoutDuration(),
cmdutil.TokenRefreshOption(cfg, host, hc),
)
_, err = client.Do(
deleteMutation,
map[string]any{
"input": map[string]any{
"id": args[0],
},
},
)
if err != nil {
return err
}
_, _ = fmt.Fprintf(
f.IOStreams.Out,
"Deleted reference %s\n",
args[0],
)
return nil
},
}
cmd.Flags().BoolVarP(&flagYes, "yes", "y", false, "Skip confirmation prompt")
return cmd
}

View File

@@ -0,0 +1,220 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package list
import (
"encoding/json"
"fmt"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
)
const listQuery = `
query($id: ID!, $first: Int, $after: CursorKey, $orderBy: CompliancePortalReferenceOrder) {
node(id: $id) {
__typename
... on Organization {
compliancePortal {
references(first: $first, after: $after, orderBy: $orderBy) {
totalCount
edges {
node {
id
name
description
websiteUrl
rank
createdAt
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
}
}
`
type compliancePortalReference struct {
ID string `json:"id"`
Name string `json:"name"`
Description *string `json:"description"`
WebsiteUrl *string `json:"websiteUrl"`
Rank int `json:"rank"`
CreatedAt string `json:"createdAt"`
}
func NewCmdList(f *cmdutil.Factory) *cobra.Command {
var (
flagOrg string
flagLimit int
flagOrderBy string
flagOrderDir string
flagOutput *string
)
cmd := &cobra.Command{
Use: "list",
Short: "List compliance portal references",
Aliases: []string{"ls"},
Example: ` # List references in the default organization
prb compliance-portal reference list
# List references sorted by rank
prb compliance-portal ref ls --order-by RANK`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if err := cmdutil.ValidateOutputFlag(flagOutput); err != nil {
return err
}
cfg, err := f.Config()
if err != nil {
return err
}
host, hc, err := cfg.DefaultHost()
if err != nil {
return err
}
client := api.NewClient(
host,
hc.Token,
"/api/console/v1/graphql",
cfg.HTTPTimeoutDuration(),
cmdutil.TokenRefreshOption(cfg, host, hc),
)
if flagOrg == "" {
flagOrg = hc.Organization
}
if flagOrg == "" {
return fmt.Errorf("organization is required; pass --org or set a default with 'prb auth login'")
}
variables := map[string]any{
"id": flagOrg,
}
if flagOrderBy != "" {
if err := cmdutil.ValidateEnum("order-by", flagOrderBy, []string{"RANK", "NAME", "CREATED_AT", "UPDATED_AT"}); err != nil {
return err
}
variables["orderBy"] = map[string]any{
"field": flagOrderBy,
"direction": flagOrderDir,
}
}
refs, totalCount, err := api.Paginate(
client,
listQuery,
variables,
flagLimit,
func(data json.RawMessage) (*api.Connection[compliancePortalReference], error) {
var resp struct {
Node *struct {
Typename string `json:"__typename"`
CompliancePortal *struct {
References api.Connection[compliancePortalReference] `json:"references"`
} `json:"compliancePortal"`
} `json:"node"`
}
if err := json.Unmarshal(data, &resp); err != nil {
return nil, err
}
if resp.Node == nil {
return nil, fmt.Errorf("organization %s not found", flagOrg)
}
if resp.Node.Typename != "Organization" {
return nil, fmt.Errorf("expected Organization node, got %s", resp.Node.Typename)
}
if resp.Node.CompliancePortal == nil {
return nil, fmt.Errorf("compliance portal not found for organization %s", flagOrg)
}
return &resp.Node.CompliancePortal.References, nil
},
)
if err != nil {
return err
}
if *flagOutput == cmdutil.OutputJSON {
return cmdutil.PrintJSON(f.IOStreams.Out, refs)
}
if len(refs) == 0 {
_, _ = fmt.Fprintln(f.IOStreams.Out, "No references found.")
return nil
}
rows := make([][]string, 0, len(refs))
for _, r := range refs {
website := ""
if r.WebsiteUrl != nil {
website = *r.WebsiteUrl
}
rows = append(rows, []string{
r.ID,
r.Name,
website,
fmt.Sprintf("%d", r.Rank),
})
}
t := cmdutil.NewTable("ID", "NAME", "WEBSITE", "RANK").Rows(rows...)
_, _ = fmt.Fprintln(f.IOStreams.Out, t)
if totalCount > len(refs) {
_, _ = fmt.Fprintf(
f.IOStreams.ErrOut,
"\nShowing %d of %d references\n",
len(refs),
totalCount,
)
}
return nil
},
}
cmd.Flags().StringVar(&flagOrg, "org", "", "Organization ID")
cmd.Flags().IntVarP(&flagLimit, "limit", "L", 30, "Maximum number of references to list")
cmd.Flags().StringVar(&flagOrderBy, "order-by", "", "Order by field (RANK, NAME, CREATED_AT, UPDATED_AT)")
cmd.Flags().StringVar(&flagOrderDir, "order-direction", "DESC", "Sort direction (ASC, DESC)")
flagOutput = cmdutil.AddOutputFlag(cmd)
return cmd
}

View File

@@ -0,0 +1,43 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package reference
import (
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cmd/cmdutil"
"go.probo.inc/probo/pkg/cmd/compliance-portal/reference/create"
"go.probo.inc/probo/pkg/cmd/compliance-portal/reference/delete"
"go.probo.inc/probo/pkg/cmd/compliance-portal/reference/list"
)
func NewCmdReference(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "reference <command>",
Short: "Manage compliance portal references",
Aliases: []string{"ref"},
}
cmd.AddCommand(list.NewCmdList(f))
cmd.AddCommand(create.NewCmdCreate(f))
cmd.AddCommand(delete.NewCmdDelete(f))
return cmd
}

View File

@@ -0,0 +1,238 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package update
import (
"encoding/json"
"fmt"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
)
const compliancePortalQuery = `
query($id: ID!) {
node(id: $id) {
__typename
... on Organization {
compliancePortal {
id
}
}
}
}
`
const updateMutation = `
mutation($input: UpdateCompliancePortalInput!) {
updateCompliancePortal(input: $input) {
compliancePortal {
id
active
searchEngineIndexing
title
description
websiteUrl
email
headquarterAddress
}
}
}
`
type compliancePortalQueryResponse struct {
Node *struct {
Typename string `json:"__typename"`
CompliancePortal *struct {
ID string `json:"id"`
} `json:"compliancePortal"`
} `json:"node"`
}
type updateResponse struct {
UpdateCompliancePortal struct {
CompliancePortal struct {
ID string `json:"id"`
Active bool `json:"active"`
SearchEngineIndexing string `json:"searchEngineIndexing"`
Title string `json:"title"`
Description *string `json:"description"`
WebsiteURL *string `json:"websiteUrl"`
Email *string `json:"email"`
HeadquarterAddress *string `json:"headquarterAddress"`
} `json:"compliancePortal"`
} `json:"updateCompliancePortal"`
}
func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
var (
flagOrg string
flagActive bool
flagSearchEngineIndexing string
flagDescription string
flagWebsiteURL string
flagEmail string
flagHeadquarterAddress string
flagTitle string
)
cmd := &cobra.Command{
Use: "update",
Short: "Update compliance portal settings",
Example: ` # Enable the compliance portal
prb compliance-portal update --active
# Disable search engine indexing
prb compliance-portal update --search-engine-indexing NOT_INDEXABLE`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
cfg, err := f.Config()
if err != nil {
return err
}
host, hc, err := cfg.DefaultHost()
if err != nil {
return err
}
client := api.NewClient(
host,
hc.Token,
"/api/console/v1/graphql",
cfg.HTTPTimeoutDuration(),
cmdutil.TokenRefreshOption(cfg, host, hc),
)
if flagOrg == "" {
flagOrg = hc.Organization
}
if flagOrg == "" {
return fmt.Errorf("organization is required; pass --org or set a default with 'prb auth login'")
}
// Fetch compliance portal ID from organization.
data, err := client.Do(
compliancePortalQuery,
map[string]any{"id": flagOrg},
)
if err != nil {
return err
}
var tcResp compliancePortalQueryResponse
if err := json.Unmarshal(data, &tcResp); err != nil {
return fmt.Errorf("cannot parse response: %w", err)
}
if tcResp.Node == nil {
return fmt.Errorf("organization %s not found", flagOrg)
}
if tcResp.Node.Typename != "Organization" {
return fmt.Errorf("expected Organization node, got %s", tcResp.Node.Typename)
}
if tcResp.Node.CompliancePortal == nil {
return fmt.Errorf("compliance portal not found for organization %s", flagOrg)
}
input := map[string]any{
"compliancePortalId": tcResp.Node.CompliancePortal.ID,
}
if cmd.Flags().Changed("active") {
input["active"] = flagActive
}
if cmd.Flags().Changed("search-engine-indexing") {
if err := cmdutil.ValidateEnum("search-engine-indexing", flagSearchEngineIndexing, []string{"INDEXABLE", "NOT_INDEXABLE"}); err != nil {
return err
}
input["searchEngineIndexing"] = flagSearchEngineIndexing
}
if cmd.Flags().Changed("description") {
input["description"] = flagDescription
}
if cmd.Flags().Changed("website-url") {
input["websiteUrl"] = flagWebsiteURL
}
if cmd.Flags().Changed("email") {
if flagEmail == "" {
input["email"] = nil
} else {
input["email"] = flagEmail
}
}
if cmd.Flags().Changed("headquarter-address") {
input["headquarterAddress"] = flagHeadquarterAddress
}
if cmd.Flags().Changed("title") {
input["title"] = flagTitle
}
if len(input) == 1 {
return fmt.Errorf("at least one field must be specified for update")
}
data, err = client.Do(
updateMutation,
map[string]any{"input": input},
)
if err != nil {
return err
}
var resp updateResponse
if err := json.Unmarshal(data, &resp); err != nil {
return fmt.Errorf("cannot parse response: %w", err)
}
tc := resp.UpdateCompliancePortal.CompliancePortal
_, _ = fmt.Fprintf(
f.IOStreams.Out,
"Updated compliance portal %s\n",
tc.ID,
)
return nil
},
}
cmd.Flags().StringVar(&flagOrg, "org", "", "Organization ID")
cmd.Flags().BoolVar(&flagActive, "active", false, "Enable or disable the compliance portal")
cmd.Flags().StringVar(&flagSearchEngineIndexing, "search-engine-indexing", "", "Search engine indexing: INDEXABLE, NOT_INDEXABLE")
cmd.Flags().StringVar(&flagDescription, "description", "", "Compliance page description")
cmd.Flags().StringVar(&flagWebsiteURL, "website-url", "", "Compliance page website URL")
cmd.Flags().StringVar(&flagEmail, "email", "", "Compliance page contact email")
cmd.Flags().StringVar(&flagHeadquarterAddress, "headquarter-address", "", "Compliance page headquarter address")
cmd.Flags().StringVar(&flagTitle, "title", "", "Public compliance page title")
return cmd
}

View File

@@ -0,0 +1,178 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package view
import (
"encoding/json"
"fmt"
"github.com/charmbracelet/lipgloss"
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
)
const viewQuery = `
query($id: ID!) {
node(id: $id) {
__typename
... on Organization {
compliancePortal {
id
active
searchEngineIndexing
logoFileUrl
darkLogoFileUrl
ndaFileName
ndaFileUrl
createdAt
updatedAt
}
}
}
}
`
type viewResponse struct {
Node *struct {
Typename string `json:"__typename"`
CompliancePortal *struct {
ID string `json:"id"`
Active bool `json:"active"`
SearchEngineIndexing string `json:"searchEngineIndexing"`
LogoFileUrl *string `json:"logoFileUrl"`
DarkLogoFileUrl *string `json:"darkLogoFileUrl"`
NdaFileName *string `json:"ndaFileName"`
NdaFileUrl *string `json:"ndaFileUrl"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
} `json:"compliancePortal"`
} `json:"node"`
}
func NewCmdView(f *cmdutil.Factory) *cobra.Command {
var (
flagOrg string
flagOutput *string
)
cmd := &cobra.Command{
Use: "view",
Short: "View compliance portal settings",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if err := cmdutil.ValidateOutputFlag(flagOutput); err != nil {
return err
}
cfg, err := f.Config()
if err != nil {
return err
}
host, hc, err := cfg.DefaultHost()
if err != nil {
return err
}
client := api.NewClient(
host,
hc.Token,
"/api/console/v1/graphql",
cfg.HTTPTimeoutDuration(),
cmdutil.TokenRefreshOption(cfg, host, hc),
)
if flagOrg == "" {
flagOrg = hc.Organization
}
if flagOrg == "" {
return fmt.Errorf("organization is required; pass --org or set a default with 'prb auth login'")
}
data, err := client.Do(
viewQuery,
map[string]any{"id": flagOrg},
)
if err != nil {
return err
}
var resp viewResponse
if err := json.Unmarshal(data, &resp); err != nil {
return fmt.Errorf("cannot parse response: %w", err)
}
if resp.Node == nil {
return fmt.Errorf("organization %s not found", flagOrg)
}
if resp.Node.Typename != "Organization" {
return fmt.Errorf("expected Organization node, got %s", resp.Node.Typename)
}
if resp.Node.CompliancePortal == nil {
return fmt.Errorf("compliance portal not found for organization %s", flagOrg)
}
tc := resp.Node.CompliancePortal
if *flagOutput == cmdutil.OutputJSON {
return cmdutil.PrintJSON(f.IOStreams.Out, tc)
}
out := f.IOStreams.Out
bold := lipgloss.NewStyle().Bold(true)
label := lipgloss.NewStyle().Foreground(lipgloss.Color("242")).Width(28)
_, _ = fmt.Fprintf(out, "%s\n\n", bold.Render("Compliance Portal"))
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("ID:"), tc.ID)
_, _ = fmt.Fprintf(out, "%s%v\n", label.Render("Active:"), tc.Active)
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Search Engine Indexing:"), tc.SearchEngineIndexing)
if tc.NdaFileName != nil && *tc.NdaFileName != "" {
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("NDA File:"), *tc.NdaFileName)
}
if tc.LogoFileUrl != nil && *tc.LogoFileUrl != "" {
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Logo URL:"), *tc.LogoFileUrl)
}
if tc.DarkLogoFileUrl != nil && *tc.DarkLogoFileUrl != "" {
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Dark Logo URL:"), *tc.DarkLogoFileUrl)
}
_, _ = fmt.Fprintln(out)
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Created:"), cmdutil.FormatTime(tc.CreatedAt))
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Updated:"), cmdutil.FormatTime(tc.UpdatedAt))
return nil
},
}
cmd.Flags().StringVar(&flagOrg, "org", "", "Organization ID")
flagOutput = cmdutil.AddOutputFlag(cmd)
return cmd
}