Skip to content
Open
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
22 changes: 12 additions & 10 deletions internal/commands/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ type AdminSetLicenseCmd struct {
}

func (c *AdminSetLicenseCmd) Run(ctx *commands.Context) error {
addList := make([]map[string]any, 0, len(c.AddLicenses))
for _, sku := range c.AddLicenses {
addList = append(addList, map[string]any{"skuId": sku})
}
args := map[string]any{
"userId": c.UserID,
"addLicenses": addList,
"removeLicenses": c.RemoveLicenses,
}

if ctx.DryRun {
return ctx.ValidateDryRun(adminEndpoint(), "mcp_Admin365_LicenseMgmtTools",
fmt.Sprintf("update licenses for user %s", c.UserID),
Expand All @@ -83,6 +93,7 @@ func (c *AdminSetLicenseCmd) Run(ctx *commands.Context) error {
"addLicenses": c.AddLicenses,
"removeLicenses": c.RemoveLicenses,
},
args,
)
}

Expand All @@ -91,16 +102,7 @@ func (c *AdminSetLicenseCmd) Run(ctx *commands.Context) error {
return fmt.Errorf("initialize: %w", err)
}

addList := make([]map[string]any, 0, len(c.AddLicenses))
for _, sku := range c.AddLicenses {
addList = append(addList, map[string]any{"skuId": sku})
}

resp, err := client.CallTool(ctx.Ctx, "mcp_Admin365_LicenseMgmtTools", map[string]any{
"userId": c.UserID,
"addLicenses": addList,
"removeLicenses": c.RemoveLicenses,
})
resp, err := client.CallTool(ctx.Ctx, "mcp_Admin365_LicenseMgmtTools", args)
if err != nil {
return fmt.Errorf("set license: %w", err)
}
Expand Down
51 changes: 29 additions & 22 deletions internal/commands/admin365/admin365.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func admin365Endpoint() string {

// Admin365Cmd groups all Admin365 subcommands.
type Admin365Cmd struct {
BulkAdd Admin365BulkAddCmd `cmd:"" name:"bulk-add" help:"Bulk add users to tenant"`
BulkAdd Admin365BulkAddCmd `cmd:"" name:"bulk-add" help:"Bulk add users to tenant"`
AgentAccess Admin365AgentAccessCmd `cmd:"" name:"agent-access" help:"Get agent access settings"`
AgentSharing Admin365AgentSharingCmd `cmd:"" name:"agent-sharing" help:"Get agent sharing settings"`
MsApps Admin365MsAppsCmd `cmd:"" name:"ms-apps" help:"Get Microsoft apps install settings"`
Expand All @@ -39,13 +39,16 @@ type Admin365BulkAddCmd struct {
}

func (c *Admin365BulkAddCmd) Run(ctx *commands.Context) error {
args := map[string]any{"fileContent": c.FileContent}

if ctx.DryRun {
return ctx.ValidateDryRun(admin365Endpoint(), "BulkAddUsers",
"bulk add users to tenant",
map[string]any{
"action": "admin365.bulk-add",
"fileContent": c.FileContent,
Comment on lines 48 to 49
},
args,
)
}

Expand All @@ -54,9 +57,7 @@ func (c *Admin365BulkAddCmd) Run(ctx *commands.Context) error {
return fmt.Errorf("initialize: %w", err)
}

resp, err := client.CallTool(ctx.Ctx, "BulkAddUsers", map[string]any{
"fileContent": c.FileContent,
})
resp, err := client.CallTool(ctx.Ctx, "BulkAddUsers", args)
if err != nil {
return fmt.Errorf("bulk add users: %w", err)
}
Expand Down Expand Up @@ -191,13 +192,16 @@ type Admin365SetAccessCmd struct {
}

func (c *Admin365SetAccessCmd) Run(ctx *commands.Context) error {
args := map[string]any{"accessLevel": c.AccessLevel}

if ctx.DryRun {
return ctx.ValidateDryRun(admin365Endpoint(), "UpdateWhoCanAccessAgentsSettings",
fmt.Sprintf("update agent access to %q", c.AccessLevel),
map[string]any{
"action": "admin365.set-access",
"accessLevel": c.AccessLevel,
},
args,
)
}

Expand All @@ -206,9 +210,7 @@ func (c *Admin365SetAccessCmd) Run(ctx *commands.Context) error {
return fmt.Errorf("initialize: %w", err)
}

resp, err := client.CallTool(ctx.Ctx, "UpdateWhoCanAccessAgentsSettings", map[string]any{
"accessLevel": c.AccessLevel,
})
resp, err := client.CallTool(ctx.Ctx, "UpdateWhoCanAccessAgentsSettings", args)
if err != nil {
return fmt.Errorf("update agent access: %w", err)
}
Expand All @@ -228,13 +230,16 @@ type Admin365SetSharingCmd struct {
}

func (c *Admin365SetSharingCmd) Run(ctx *commands.Context) error {
args := map[string]any{"accessLevel": c.AccessLevel}

if ctx.DryRun {
return ctx.ValidateDryRun(admin365Endpoint(), "UpdateWhoCanShareAgentsOrgWideSettings",
fmt.Sprintf("update agent sharing to %q", c.AccessLevel),
map[string]any{
"action": "admin365.set-sharing",
"accessLevel": c.AccessLevel,
},
args,
)
}

Expand All @@ -243,9 +248,7 @@ func (c *Admin365SetSharingCmd) Run(ctx *commands.Context) error {
return fmt.Errorf("initialize: %w", err)
}

resp, err := client.CallTool(ctx.Ctx, "UpdateWhoCanShareAgentsOrgWideSettings", map[string]any{
"accessLevel": c.AccessLevel,
})
resp, err := client.CallTool(ctx.Ctx, "UpdateWhoCanShareAgentsOrgWideSettings", args)
if err != nil {
return fmt.Errorf("update agent sharing: %w", err)
}
Expand All @@ -265,13 +268,16 @@ type Admin365SetMsAppsCmd struct {
}

func (c *Admin365SetMsAppsCmd) Run(ctx *commands.Context) error {
args := map[string]any{"allowed": c.Allowed}

if ctx.DryRun {
return ctx.ValidateDryRun(admin365Endpoint(), "UpdateCanInstallMicrosoftAppsAndAgentsSettings",
fmt.Sprintf("update Microsoft apps install to %s", c.Allowed),
map[string]any{
"action": "admin365.set-ms-apps",
"allowed": c.Allowed,
},
args,
)
}

Expand All @@ -280,9 +286,7 @@ func (c *Admin365SetMsAppsCmd) Run(ctx *commands.Context) error {
return fmt.Errorf("initialize: %w", err)
}

resp, err := client.CallTool(ctx.Ctx, "UpdateCanInstallMicrosoftAppsAndAgentsSettings", map[string]any{
"allowed": c.Allowed,
})
resp, err := client.CallTool(ctx.Ctx, "UpdateCanInstallMicrosoftAppsAndAgentsSettings", args)
if err != nil {
return fmt.Errorf("update Microsoft apps settings: %w", err)
}
Expand All @@ -302,13 +306,16 @@ type Admin365SetThirdPartyCmd struct {
}

func (c *Admin365SetThirdPartyCmd) Run(ctx *commands.Context) error {
args := map[string]any{"allowed": c.Allowed}

if ctx.DryRun {
return ctx.ValidateDryRun(admin365Endpoint(), "UpdateCanInstallThirdPartyAppsAndAgentsSettings",
fmt.Sprintf("update third-party apps install to %s", c.Allowed),
map[string]any{
"action": "admin365.set-third-party",
"allowed": c.Allowed,
},
args,
)
}

Expand All @@ -317,9 +324,7 @@ func (c *Admin365SetThirdPartyCmd) Run(ctx *commands.Context) error {
return fmt.Errorf("initialize: %w", err)
}

resp, err := client.CallTool(ctx.Ctx, "UpdateCanInstallThirdPartyAppsAndAgentsSettings", map[string]any{
"allowed": c.Allowed,
})
resp, err := client.CallTool(ctx.Ctx, "UpdateCanInstallThirdPartyAppsAndAgentsSettings", args)
if err != nil {
return fmt.Errorf("update third-party apps settings: %w", err)
}
Expand All @@ -339,13 +344,16 @@ type Admin365SetLobAppsCmd struct {
}

func (c *Admin365SetLobAppsCmd) Run(ctx *commands.Context) error {
args := map[string]any{"allowed": c.Allowed}

if ctx.DryRun {
return ctx.ValidateDryRun(admin365Endpoint(), "UpdateCanInstallLOBAppsAndAgentsSettings",
fmt.Sprintf("update LOB apps install to %s", c.Allowed),
map[string]any{
"action": "admin365.set-lob-apps",
"allowed": c.Allowed,
},
args,
)
}

Expand All @@ -354,9 +362,7 @@ func (c *Admin365SetLobAppsCmd) Run(ctx *commands.Context) error {
return fmt.Errorf("initialize: %w", err)
}

resp, err := client.CallTool(ctx.Ctx, "UpdateCanInstallLOBAppsAndAgentsSettings", map[string]any{
"allowed": c.Allowed,
})
resp, err := client.CallTool(ctx.Ctx, "UpdateCanInstallLOBAppsAndAgentsSettings", args)
if err != nil {
return fmt.Errorf("update LOB apps settings: %w", err)
}
Expand Down Expand Up @@ -422,13 +428,16 @@ type Admin365SetCopilotCmd struct {
}

func (c *Admin365SetCopilotCmd) Run(ctx *commands.Context) error {
args := map[string]any{"isEnabled": c.IsEnabled}

if ctx.DryRun {
return ctx.ValidateDryRun(admin365Endpoint(), "UpdateCopilotAdminSettings",
fmt.Sprintf("update Copilot admin setting to isEnabled=%s", c.IsEnabled),
map[string]any{
"action": "admin365.set-copilot",
"isEnabled": c.IsEnabled,
},
args,
)
}

Expand All @@ -437,9 +446,7 @@ func (c *Admin365SetCopilotCmd) Run(ctx *commands.Context) error {
return fmt.Errorf("initialize: %w", err)
}

resp, err := client.CallTool(ctx.Ctx, "UpdateCopilotAdminSettings", map[string]any{
"isEnabled": c.IsEnabled,
})
resp, err := client.CallTool(ctx.Ctx, "UpdateCopilotAdminSettings", args)
if err != nil {
return fmt.Errorf("update Copilot admin settings: %w", err)
}
Expand Down
Loading