Add missing resources to CLI, MCP, and n8n surfaces
Audit all three API surfaces against the console GraphQL schema and add missing resources: asset, audit, datum, dpia, evidence upload, measure, obligation, processing activity, rights request, snapshot, task, tia, trust center (with references/files), and vendor management CLI commands; MCP tools for deletes, rights requests, trust center, vendor contacts/services, and compliance external URLs; n8n nodes for obligation, finding, task, evidence, processing activity, dpia, tia, rights request, snapshot, audit log, access review, organization context, trust center, and additional control/measure/vendor operations. Include MCP e2e test infrastructure (testutil MCP client with API key auth and JSON-RPC session management) and tests covering all new MCP tools. Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
147
pkg/cmd/tia/create/create.go
Normal file
147
pkg/cmd/tia/create/create.go
Normal file
@@ -0,0 +1,147 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package create
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"go.probo.inc/probo/pkg/cli/api"
|
||||
"go.probo.inc/probo/pkg/cmd/cmdutil"
|
||||
)
|
||||
|
||||
const createMutation = `
|
||||
mutation($input: CreateTransferImpactAssessmentInput!) {
|
||||
createTransferImpactAssessment(input: $input) {
|
||||
transferImpactAssessmentEdge {
|
||||
node {
|
||||
id
|
||||
dataSubjects
|
||||
legalMechanism
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
type createResponse struct {
|
||||
CreateTransferImpactAssessment struct {
|
||||
TransferImpactAssessmentEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
DataSubjects string `json:"dataSubjects"`
|
||||
LegalMechanism string `json:"legalMechanism"`
|
||||
} `json:"node"`
|
||||
} `json:"transferImpactAssessmentEdge"`
|
||||
} `json:"createTransferImpactAssessment"`
|
||||
}
|
||||
|
||||
func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
|
||||
var (
|
||||
flagProcessingActivity string
|
||||
flagDataSubjects string
|
||||
flagLegalMechanism string
|
||||
flagTransfer string
|
||||
flagLocalLawRisk string
|
||||
flagSupplementaryMeasures string
|
||||
)
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "create",
|
||||
Short: "Create a new transfer impact assessment",
|
||||
Example: ` # Create a TIA
|
||||
prb tia create --processing-activity <id> --data-subjects "EU residents"
|
||||
|
||||
# Create a TIA with all fields
|
||||
prb tia create --processing-activity <id> --data-subjects "EU residents" --legal-mechanism "SCCs" --transfer "US" --local-law-risk "FISA 702" --supplementary-measures "Encryption"`,
|
||||
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 flagProcessingActivity == "" {
|
||||
return fmt.Errorf("processing activity is required; pass --processing-activity")
|
||||
}
|
||||
|
||||
input := map[string]any{
|
||||
"processingActivityId": flagProcessingActivity,
|
||||
}
|
||||
|
||||
if flagDataSubjects != "" {
|
||||
input["dataSubjects"] = flagDataSubjects
|
||||
}
|
||||
if flagLegalMechanism != "" {
|
||||
input["legalMechanism"] = flagLegalMechanism
|
||||
}
|
||||
if flagTransfer != "" {
|
||||
input["transfer"] = flagTransfer
|
||||
}
|
||||
if flagLocalLawRisk != "" {
|
||||
input["localLawRisk"] = flagLocalLawRisk
|
||||
}
|
||||
if flagSupplementaryMeasures != "" {
|
||||
input["supplementaryMeasures"] = flagSupplementaryMeasures
|
||||
}
|
||||
|
||||
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.CreateTransferImpactAssessment.TransferImpactAssessmentEdge.Node
|
||||
_, _ = fmt.Fprintf(
|
||||
f.IOStreams.Out,
|
||||
"Created transfer impact assessment %s\n",
|
||||
r.ID,
|
||||
)
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().StringVar(&flagProcessingActivity, "processing-activity", "", "Processing activity ID (required)")
|
||||
cmd.Flags().StringVar(&flagDataSubjects, "data-subjects", "", "Data subjects")
|
||||
cmd.Flags().StringVar(&flagLegalMechanism, "legal-mechanism", "", "Legal mechanism")
|
||||
cmd.Flags().StringVar(&flagTransfer, "transfer", "", "Transfer")
|
||||
cmd.Flags().StringVar(&flagLocalLawRisk, "local-law-risk", "", "Local law risk")
|
||||
cmd.Flags().StringVar(&flagSupplementaryMeasures, "supplementary-measures", "", "Supplementary measures")
|
||||
|
||||
_ = cmd.MarkFlagRequired("processing-activity")
|
||||
|
||||
return cmd
|
||||
}
|
||||
103
pkg/cmd/tia/delete/delete.go
Normal file
103
pkg/cmd/tia/delete/delete.go
Normal file
@@ -0,0 +1,103 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS 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: DeleteTransferImpactAssessmentInput!) {
|
||||
deleteTransferImpactAssessment(input: $input) {
|
||||
deletedTransferImpactAssessmentId
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
func NewCmdDelete(f *cmdutil.Factory) *cobra.Command {
|
||||
var flagYes bool
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "delete <id>",
|
||||
Short: "Delete a transfer impact assessment",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if !flagYes {
|
||||
if !f.IOStreams.IsInteractive() {
|
||||
return fmt.Errorf("cannot delete transfer impact assessment: confirmation required, use --yes to confirm")
|
||||
}
|
||||
|
||||
var confirmed bool
|
||||
err := huh.NewConfirm().
|
||||
Title(fmt.Sprintf("Delete transfer impact assessment %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{
|
||||
"transferImpactAssessmentId": args[0],
|
||||
},
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintf(
|
||||
f.IOStreams.Out,
|
||||
"Deleted transfer impact assessment %s\n",
|
||||
args[0],
|
||||
)
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().BoolVarP(&flagYes, "yes", "y", false, "Skip confirmation prompt")
|
||||
|
||||
return cmd
|
||||
}
|
||||
195
pkg/cmd/tia/list/list.go
Normal file
195
pkg/cmd/tia/list/list.go
Normal file
@@ -0,0 +1,195 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS 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: TransferImpactAssessmentOrder) {
|
||||
node(id: $id) {
|
||||
__typename
|
||||
... on Organization {
|
||||
transferImpactAssessments(first: $first, after: $after, orderBy: $orderBy) {
|
||||
totalCount
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
dataSubjects
|
||||
legalMechanism
|
||||
createdAt
|
||||
}
|
||||
}
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
endCursor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
type transferImpactAssessment struct {
|
||||
ID string `json:"id"`
|
||||
DataSubjects string `json:"dataSubjects"`
|
||||
LegalMechanism string `json:"legalMechanism"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
}
|
||||
|
||||
func truncate(s string, max int) string {
|
||||
if len(s) <= max {
|
||||
return s
|
||||
}
|
||||
return s[:max-3] + "..."
|
||||
}
|
||||
|
||||
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 transfer impact assessments in an organization",
|
||||
Aliases: []string{"ls"},
|
||||
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{"CREATED_AT"}); err != nil {
|
||||
return err
|
||||
}
|
||||
variables["orderBy"] = map[string]any{
|
||||
"field": flagOrderBy,
|
||||
"direction": flagOrderDir,
|
||||
}
|
||||
}
|
||||
|
||||
tias, totalCount, err := api.Paginate(
|
||||
client,
|
||||
listQuery,
|
||||
variables,
|
||||
flagLimit,
|
||||
func(data json.RawMessage) (*api.Connection[transferImpactAssessment], error) {
|
||||
var resp struct {
|
||||
Node *struct {
|
||||
Typename string `json:"__typename"`
|
||||
TransferImpactAssessments api.Connection[transferImpactAssessment] `json:"transferImpactAssessments"`
|
||||
} `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.TransferImpactAssessments, nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if *flagOutput == cmdutil.OutputJSON {
|
||||
return cmdutil.PrintJSON(f.IOStreams.Out, tias)
|
||||
}
|
||||
|
||||
if len(tias) == 0 {
|
||||
_, _ = fmt.Fprintln(f.IOStreams.Out, "No transfer impact assessments found.")
|
||||
return nil
|
||||
}
|
||||
|
||||
rows := make([][]string, 0, len(tias))
|
||||
for _, t := range tias {
|
||||
rows = append(rows, []string{
|
||||
t.ID,
|
||||
truncate(t.DataSubjects, 50),
|
||||
truncate(t.LegalMechanism, 50),
|
||||
cmdutil.FormatTime(t.CreatedAt),
|
||||
})
|
||||
}
|
||||
|
||||
tbl := cmdutil.NewTable("ID", "DATA SUBJECTS", "LEGAL MECHANISM", "CREATED AT").Rows(rows...)
|
||||
|
||||
_, _ = fmt.Fprintln(f.IOStreams.Out, tbl)
|
||||
|
||||
if totalCount > len(tias) {
|
||||
_, _ = fmt.Fprintf(
|
||||
f.IOStreams.ErrOut,
|
||||
"\nShowing %d of %d transfer impact assessments\n",
|
||||
len(tias),
|
||||
totalCount,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().StringVar(&flagOrg, "org", "", "Organization ID")
|
||||
cmd.Flags().IntVarP(&flagLimit, "limit", "L", 30, "Maximum number of transfer impact assessments to list")
|
||||
cmd.Flags().StringVar(&flagOrderBy, "order-by", "", "Order by field (CREATED_AT)")
|
||||
cmd.Flags().StringVar(&flagOrderDir, "order-direction", "DESC", "Sort direction (ASC, DESC)")
|
||||
flagOutput = cmdutil.AddOutputFlag(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
40
pkg/cmd/tia/tia.go
Normal file
40
pkg/cmd/tia/tia.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package tia
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"go.probo.inc/probo/pkg/cmd/cmdutil"
|
||||
"go.probo.inc/probo/pkg/cmd/tia/create"
|
||||
"go.probo.inc/probo/pkg/cmd/tia/delete"
|
||||
"go.probo.inc/probo/pkg/cmd/tia/list"
|
||||
"go.probo.inc/probo/pkg/cmd/tia/update"
|
||||
"go.probo.inc/probo/pkg/cmd/tia/view"
|
||||
)
|
||||
|
||||
func NewCmdTIA(f *cmdutil.Factory) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "tia <command>",
|
||||
Short: "Manage transfer impact assessments",
|
||||
}
|
||||
|
||||
cmd.AddCommand(list.NewCmdList(f))
|
||||
cmd.AddCommand(create.NewCmdCreate(f))
|
||||
cmd.AddCommand(view.NewCmdView(f))
|
||||
cmd.AddCommand(update.NewCmdUpdate(f))
|
||||
cmd.AddCommand(delete.NewCmdDelete(f))
|
||||
|
||||
return cmd
|
||||
}
|
||||
135
pkg/cmd/tia/update/update.go
Normal file
135
pkg/cmd/tia/update/update.go
Normal file
@@ -0,0 +1,135 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS 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: UpdateTransferImpactAssessmentInput!) {
|
||||
updateTransferImpactAssessment(input: $input) {
|
||||
transferImpactAssessment {
|
||||
id
|
||||
dataSubjects
|
||||
legalMechanism
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
type updateResponse struct {
|
||||
UpdateTransferImpactAssessment struct {
|
||||
TransferImpactAssessment struct {
|
||||
ID string `json:"id"`
|
||||
DataSubjects string `json:"dataSubjects"`
|
||||
LegalMechanism string `json:"legalMechanism"`
|
||||
} `json:"transferImpactAssessment"`
|
||||
} `json:"updateTransferImpactAssessment"`
|
||||
}
|
||||
|
||||
func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
|
||||
var (
|
||||
flagDataSubjects string
|
||||
flagLegalMechanism string
|
||||
flagTransfer string
|
||||
flagLocalLawRisk string
|
||||
flagSupplementaryMeasures string
|
||||
)
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "update <id>",
|
||||
Short: "Update a transfer impact assessment",
|
||||
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("data-subjects") {
|
||||
input["dataSubjects"] = flagDataSubjects
|
||||
}
|
||||
if cmd.Flags().Changed("legal-mechanism") {
|
||||
input["legalMechanism"] = flagLegalMechanism
|
||||
}
|
||||
if cmd.Flags().Changed("transfer") {
|
||||
input["transfer"] = flagTransfer
|
||||
}
|
||||
if cmd.Flags().Changed("local-law-risk") {
|
||||
input["localLawRisk"] = flagLocalLawRisk
|
||||
}
|
||||
if cmd.Flags().Changed("supplementary-measures") {
|
||||
input["supplementaryMeasures"] = flagSupplementaryMeasures
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
r := resp.UpdateTransferImpactAssessment.TransferImpactAssessment
|
||||
_, _ = fmt.Fprintf(
|
||||
f.IOStreams.Out,
|
||||
"Updated transfer impact assessment %s\n",
|
||||
r.ID,
|
||||
)
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().StringVar(&flagDataSubjects, "data-subjects", "", "Data subjects")
|
||||
cmd.Flags().StringVar(&flagLegalMechanism, "legal-mechanism", "", "Legal mechanism")
|
||||
cmd.Flags().StringVar(&flagTransfer, "transfer", "", "Transfer")
|
||||
cmd.Flags().StringVar(&flagLocalLawRisk, "local-law-risk", "", "Local law risk")
|
||||
cmd.Flags().StringVar(&flagSupplementaryMeasures, "supplementary-measures", "", "Supplementary measures")
|
||||
|
||||
return cmd
|
||||
}
|
||||
155
pkg/cmd/tia/view/view.go
Normal file
155
pkg/cmd/tia/view/view.go
Normal file
@@ -0,0 +1,155 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS 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 TransferImpactAssessment {
|
||||
id
|
||||
dataSubjects
|
||||
legalMechanism
|
||||
transfer
|
||||
localLawRisk
|
||||
supplementaryMeasures
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
type viewResponse struct {
|
||||
Node *struct {
|
||||
Typename string `json:"__typename"`
|
||||
ID string `json:"id"`
|
||||
DataSubjects string `json:"dataSubjects"`
|
||||
LegalMechanism string `json:"legalMechanism"`
|
||||
Transfer string `json:"transfer"`
|
||||
LocalLawRisk string `json:"localLawRisk"`
|
||||
SupplementaryMeasures string `json:"supplementaryMeasures"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
} `json:"node"`
|
||||
}
|
||||
|
||||
func NewCmdView(f *cmdutil.Factory) *cobra.Command {
|
||||
var flagOutput *string
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "view <id>",
|
||||
Short: "View a transfer impact assessment",
|
||||
Args: cobra.ExactArgs(1),
|
||||
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),
|
||||
)
|
||||
|
||||
data, err := client.Do(
|
||||
viewQuery,
|
||||
map[string]any{"id": args[0]},
|
||||
)
|
||||
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("transfer impact assessment %s not found", args[0])
|
||||
}
|
||||
|
||||
if resp.Node.Typename != "TransferImpactAssessment" {
|
||||
return fmt.Errorf("expected TransferImpactAssessment node, got %s", resp.Node.Typename)
|
||||
}
|
||||
|
||||
if *flagOutput == cmdutil.OutputJSON {
|
||||
return cmdutil.PrintJSON(f.IOStreams.Out, resp.Node)
|
||||
}
|
||||
|
||||
r := resp.Node
|
||||
out := f.IOStreams.Out
|
||||
|
||||
bold := lipgloss.NewStyle().Bold(true)
|
||||
label := lipgloss.NewStyle().Foreground(lipgloss.Color("242")).Width(26)
|
||||
|
||||
_, _ = fmt.Fprintf(out, "%s\n\n", bold.Render("Transfer Impact Assessment"))
|
||||
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("ID:"), r.ID)
|
||||
|
||||
if r.DataSubjects != "" {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Data Subjects:"), r.DataSubjects)
|
||||
}
|
||||
|
||||
if r.LegalMechanism != "" {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Legal Mechanism:"), r.LegalMechanism)
|
||||
}
|
||||
|
||||
if r.Transfer != "" {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Transfer:"), r.Transfer)
|
||||
}
|
||||
|
||||
if r.LocalLawRisk != "" {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Local Law Risk:"), r.LocalLawRisk)
|
||||
}
|
||||
|
||||
if r.SupplementaryMeasures != "" {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Supplementary Measures:"), r.SupplementaryMeasures)
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintln(out)
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Created:"), cmdutil.FormatTime(r.CreatedAt))
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Updated:"), cmdutil.FormatTime(r.UpdatedAt))
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
flagOutput = cmdutil.AddOutputFlag(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
Reference in New Issue
Block a user