Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func makeChildCommand(root RootCommand, desc map[string]cmdutils.Descriptor) *co
&cobra.Group{ID: "configuration-manager", Title: "Configuration Manager Commands:"},
&cobra.Group{ID: "operations-manager", Title: "Operations Manager Commands:"},
&cobra.Group{ID: "lifecycle-manager", Title: "Lifecycle Manager Commands:"},
&cobra.Group{ID: "flow-agent", Title: "Flow Agent Commands:"},
)
}

Expand Down
25 changes: 25 additions & 0 deletions internal/flags/agent_projects.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2024 Itential Inc. All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited
// Proprietary and confidential

package flags

import "github.com/spf13/cobra"

// AgentProjectImportOptions holds options for the `import agent-project` command.
type AgentProjectImportOptions struct {
Members []string
ConflictMode string
}

func (o *AgentProjectImportOptions) Flags(cmd *cobra.Command) {
cmd.Flags().StringArrayVar(&o.Members, "member", o.Members, "Configure one or more project members")
// Left unset by default (empty string) so the runner can distinguish "not specified" from
// an explicit choice: --replace implies conflict-mode=replace unless --conflict-mode overrides it.
cmd.Flags().StringVar(&o.ConflictMode, "conflict-mode", "", "How to handle a collision with an existing project (keep-both or replace); defaults to \"replace\" if --replace is set, otherwise \"keep-both\"")
}

// AgentProjectExportOptions holds options for the `export agent-project` command.
type AgentProjectExportOptions struct{}

func (o *AgentProjectExportOptions) Flags(_ *cobra.Command) {}
23 changes: 23 additions & 0 deletions internal/flags/agent_projects_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2024 Itential Inc. All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited
// Proprietary and confidential

package flags

import (
"testing"

"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
)

func TestAgentProjectImportOptions_Flags(t *testing.T) {
checkFlags(t, &AgentProjectImportOptions{}, []string{"member"})
}

func TestAgentProjectExportOptions_Flags(t *testing.T) {
opts := &AgentProjectExportOptions{}
cmd := &cobra.Command{}
opts.Flags(cmd)
assert.NotNil(t, opts)
}
21 changes: 21 additions & 0 deletions internal/handlers/agent_projects.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2024 Itential Inc. All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited
// Proprietary and confidential

package handlers

import (
"github.com/itential/ipctl/internal/flags"
"github.com/itential/ipctl/internal/runners"
)

func NewAgentProjectHandler(rt *Runtime, desc Descriptors) AssetHandler {
return NewAssetHandler(
runners.NewAgentProjectRunner(rt.GetClient(), rt.GetConfig()),
desc[agentProjectsDescriptor],
&AssetHandlerFlags{
Import: &flags.AgentProjectImportOptions{},
Export: &flags.AgentProjectExportOptions{},
},
)
}
2 changes: 2 additions & 0 deletions internal/handlers/descriptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const (
configurationParsersDescriptor = "configuration_parsers"
gctreesDescriptor = "gctrees"

agentProjectsDescriptor = "agent_projects"

serverDescriptor = "server"

localAAADescriptor = "localaaa"
Expand Down
75 changes: 75 additions & 0 deletions internal/handlers/descriptors/agent_projects.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright 2025 Itential Inc. All Rights Reserved
# Unauthorized copying of this file, via any medium is strictly prohibited
# Proprietary and confidential
---
get:
use: agent-projects
group: flow-agent

description: |
Display one or more agent projects.

The `get agent-projects` command will retrieve all configured agent projects
from the FlowAI server and display them in table format by default. If
there are no configured agent projects, the command will return an empty table.

example: |
# Display all configured agent projects
$ ipctl get agent-projects

describe:
use: agent-project <name>
group: flow-agent

description: |
Display details about an agent project.

The `describe agent-project <name>` command will retrieve the specified
agent project from the FlowAI server, if it exists, and display it.
If the specified agent project does not exist, this command will return
an error.

example: |
# Display details about an agent project called `my-agents`
$ ipctl describe agent-project "my-agents"

import:
use: agent-project <path>
group: flow-agent

description: |
Import an agent project.

The `import agent-project` command will import an agent project bundle
into the FlowAI service. The path argument must point to a JSON file
containing an exported agent project bundle.

If an agent project with the same name already exists on the server,
this command will return an error.

example: |
# Import an agent project from a file
$ ipctl import agent-project path/to/my-agents.agent-project.json

export:
use: agent-project <name>
group: flow-agent

exact_args: 1

description: |
Export an agent project.

The `export agent-project <name>` command will export the specified agent
project bundle from the FlowAI service. The exported bundle is saved as
a JSON file named after the project.

If a `--path` or `--repository` option is provided, the file will be
written to the specified location or committed to the Git repository.

example: |
# Export an agent project to the current directory
$ ipctl export agent-project "my-agents"

# Export an agent project to a specific directory
$ ipctl export agent-project "my-agents" --path /tmp/exports
3 changes: 3 additions & 0 deletions internal/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ func NewHandler(rt *Runtime) Handler {
// Lifecycle Manager handlers
NewModelHandler(rt, descriptors),

// Flow Agent handlers
NewAgentProjectHandler(rt, descriptors),

NewServerHandler(rt, descriptors),
}

Expand Down
Loading