Skip to content

Commit

Permalink
Merge pull request #2 from chrlesur/dev
Browse files Browse the repository at this point in the history
1.1.0 Beta realease
  • Loading branch information
chrlesur authored Sep 15, 2024
2 parents 8f0a7a3 + 0434b08 commit 726b68d
Show file tree
Hide file tree
Showing 9 changed files with 277 additions and 139 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ RTMS CLI is a command-line interface for interacting with the RTMS (Real-Time Mo

## Version

- 20240914 - 1.00 Beta Release
- 20240914 - 1.0.0 Beta Release
- 20240914 - 1.1.0 Beta Release - Enhanced catalogs and appliances management - Enhanced markdown output.

## Features

Expand Down Expand Up @@ -93,6 +94,7 @@ Before using RTMS CLI, you need to configure your RTMS API key. Set the `RTMS_AP
```
setx RTMS_API_KEY "your_api_key_here"
```
note : reload your shell after

#### macOS and Linux
```
Expand All @@ -118,7 +120,7 @@ Here are some basic usage examples of RTMS CLI:
rtmscli version
# List appliances
rtmscli -c cloud_temple_id get-appliances list
rtmscli -c cloud_temple_id appliances list
# Create a ticket
rtmscli -c cloud_temple_id tickets create --name="New ticket" --description="Ticket description"
Expand Down
File renamed without changes.
Binary file added binary/rtmscli-1.1.0-beta.exe
Binary file not shown.
70 changes: 28 additions & 42 deletions cmd/appliances.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,102 +6,99 @@ import (
"github.com/spf13/cobra"
)

var appliancesCmd = &cobra.Command{
Use: "appliances",
Short: "Manage appliances",
Long: `Commands to manage and interact with appliances in the RTMS system.`,
}

func init() {
rootCmd.AddCommand(getAppliancesCmd)
rootCmd.AddCommand(getApplianceDetailsCmd)
rootCmd.AddCommand(getApplianceServicesCmd)
rootCmd.AddCommand(synchronizeApplianceCmd)
rootCmd.AddCommand(getApplianceConfigurationCmd)
rootCmd.AddCommand(getApplianceHealthCheckCmd)
rootCmd.AddCommand(postApplianceHealthCheckCmd)
rootCmd.AddCommand(appliancesCmd)

// Subcommands
appliancesCmd.AddCommand(getAppliancesCmd)
appliancesCmd.AddCommand(getApplianceDetailsCmd)
appliancesCmd.AddCommand(getApplianceServicesCmd)
appliancesCmd.AddCommand(synchronizeApplianceCmd)
appliancesCmd.AddCommand(getApplianceConfigurationCmd)
appliancesCmd.AddCommand(getApplianceHealthCheckCmd)
appliancesCmd.AddCommand(postApplianceHealthCheckCmd)
}

var getAppliancesCmd = &cobra.Command{
Use: "get-appliances",
Use: "list",
Short: "Get a list of appliances",
RunE: func(cmd *cobra.Command, args []string) error {
cloudTempleID, _ := cmd.Flags().GetString("cloud-temple-id")
response, err := client.GetAppliances(cloudTempleID)
if err != nil {
return err
}
// Utilisation de formatOutput pour formater la réponse
formattedOutput, err := formatOutput(response)
if err != nil {
return err
}

// Affichage de la réponse formatée
fmt.Println(formattedOutput)
return nil
},
}

var getApplianceDetailsCmd = &cobra.Command{
Use: "get-appliance-details [id]",
Use: "details [id]",
Short: "Get Appliance details",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
response, err := client.GetApplianceDetails(args[0])
if err != nil {
return err
}
// Utilisation de formatOutput pour formater la réponse
formattedOutput, err := formatOutput(response)
if err != nil {
return err
}

// Affichage de la réponse formatée
fmt.Println(formattedOutput)
return nil
},
}

var getApplianceServicesCmd = &cobra.Command{
Use: "get-appliance-services [id]",
Use: "services [id]",
Short: "Get Appliance services",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
response, err := client.GetApplianceServices(args[0])
if err != nil {
return err
}
// Utilisation de formatOutput pour formater la réponse
formattedOutput, err := formatOutput(response)
if err != nil {
return err
}

// Affichage de la réponse formatée
fmt.Println(formattedOutput)
return nil
},
}

var synchronizeApplianceCmd = &cobra.Command{
Use: "synchronize-appliance [id]",
Use: "synchronize [id]",
Short: "Synchronize Appliance",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
response, err := client.SynchronizeAppliance(args[0])
if err != nil {
return err
}
// Utilisation de formatOutput pour formater la réponse
formattedOutput, err := formatOutput(response)
if err != nil {
return err
}

// Affichage de la réponse formatée
fmt.Println(formattedOutput)
return nil
},
}

var getApplianceConfigurationCmd = &cobra.Command{
Use: "get-appliance-configuration [id]",
Use: "configuration [id]",
Short: "Get appliances configuration",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -111,48 +108,35 @@ var getApplianceConfigurationCmd = &cobra.Command{
if err != nil {
return err
}
// Utilisation de formatOutput pour formater la réponse
formattedOutput, err := formatOutput(response)
if err != nil {
return err
}

// Affichage de la réponse formatée
fmt.Println(formattedOutput)
return nil
},
}

func init() {
getApplianceConfigurationCmd.Flags().String("appliance-version", "", "Appliance version")
getApplianceConfigurationCmd.Flags().String("plugins-path", "", "Absolute path to the plugins installation directory on the appliance")
getApplianceConfigurationCmd.MarkFlagRequired("appliance-version")
getApplianceConfigurationCmd.MarkFlagRequired("plugins-path")
}

var getApplianceHealthCheckCmd = &cobra.Command{
Use: "get-appliance-healthcheck [id]",
Use: "healthcheck [id]",
Short: "Get a last heartbeat of an appliance",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
response, err := client.GetApplianceHealthCheck(args[0])
if err != nil {
return err
}
// Utilisation de formatOutput pour formater la réponse
formattedOutput, err := formatOutput(response)
if err != nil {
return err
}

// Affichage de la réponse formatée
fmt.Println(formattedOutput)
return nil
},
}

var postApplianceHealthCheckCmd = &cobra.Command{
Use: "post-appliance-healthcheck [id]",
Use: "post-healthcheck [id]",
Short: "Posts an appliance heartbeat",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -170,19 +154,21 @@ var postApplianceHealthCheckCmd = &cobra.Command{
if err != nil {
return err
}
// Utilisation de formatOutput pour formater la réponse
formattedOutput, err := formatOutput(response)
if err != nil {
return err
}

// Affichage de la réponse formatée
fmt.Println(formattedOutput)
return nil
},
}

func init() {
getApplianceConfigurationCmd.Flags().String("appliance-version", "", "Appliance version")
getApplianceConfigurationCmd.Flags().String("plugins-path", "", "Absolute path to the plugins installation directory on the appliance")
getApplianceConfigurationCmd.MarkFlagRequired("appliance-version")
getApplianceConfigurationCmd.MarkFlagRequired("plugins-path")

postApplianceHealthCheckCmd.Flags().String("appliance-version", "", "Appliance version")
postApplianceHealthCheckCmd.Flags().String("nagios-operating-state", "", "Nagios operating state (OK, WARNING, CRITICAL)")
postApplianceHealthCheckCmd.Flags().String("details", "", "Any details to explain the current operating state")
Expand Down
38 changes: 18 additions & 20 deletions cmd/catalogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,45 @@ import (
"github.com/spf13/cobra"
)

var catalogsCmd = &cobra.Command{
Use: "catalogs",
Short: "Manage ticket classification catalogs",
Long: `Commands to manage and interact with ticket classification catalogs in the RTMS system.`,
}

func init() {
rootCmd.AddCommand(getCatalogsCmd)
rootCmd.AddCommand(getDefaultCatalogsCmd)
rootCmd.AddCommand(getCatalogItemsCmd)
rootCmd.AddCommand(getRootCatalogCmd)
rootCmd.AddCommand(catalogsCmd)

// Subcommands
catalogsCmd.AddCommand(getCatalogsCmd)
catalogsCmd.AddCommand(getDefaultCatalogsCmd)
catalogsCmd.AddCommand(getCatalogItemsCmd)
catalogsCmd.AddCommand(getRootCatalogCmd)
}

var getCatalogsCmd = &cobra.Command{
Use: "get-catalogs",
Use: "list",
Short: "Get a list of Ticket classification catalogs and items",
RunE: func(cmd *cobra.Command, args []string) error {
cloudTempleID, _ := cmd.Flags().GetString("cloud-temple-id")
availableItems, _ := cmd.Flags().GetBool("available-items")
isRoot, _ := cmd.Flags().GetBool("is-root")

response, err := client.GetCatalogs(cloudTempleID, availableItems, isRoot)
if err != nil {
return err
}
// Utilisation de formatOutput pour formater la réponse
formattedOutput, err := formatOutput(response)
if err != nil {
return err
}

// Affichage de la réponse formatée
fmt.Println(formattedOutput)
return nil
},
}

var getDefaultCatalogsCmd = &cobra.Command{
Use: "get-default-catalogs",
Use: "defaults",
Short: "Get a list of all default ticket classification catalogs and catalog items",
RunE: func(cmd *cobra.Command, args []string) error {
availableItems, _ := cmd.Flags().GetBool("available-items")
Expand All @@ -47,20 +54,17 @@ var getDefaultCatalogsCmd = &cobra.Command{
if err != nil {
return err
}
// Utilisation de formatOutput pour formater la réponse
formattedOutput, err := formatOutput(response)
if err != nil {
return err
}

// Affichage de la réponse formatée
fmt.Println(formattedOutput)
return nil
},
}

var getCatalogItemsCmd = &cobra.Command{
Use: "get-catalog-items [catalog-id]",
Use: "items [catalog-id]",
Short: "Get a list of items for a catalog",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -75,20 +79,17 @@ var getCatalogItemsCmd = &cobra.Command{
if err != nil {
return err
}
// Utilisation de formatOutput pour formater la réponse
formattedOutput, err := formatOutput(response)
if err != nil {
return err
}

// Affichage de la réponse formatée
fmt.Println(formattedOutput)
return nil
},
}

var getRootCatalogCmd = &cobra.Command{
Use: "get-root-catalog",
Use: "root",
Short: "Get the root required catalog",
RunE: func(cmd *cobra.Command, args []string) error {
catalogType, _ := cmd.Flags().GetString("type")
Expand All @@ -98,13 +99,10 @@ var getRootCatalogCmd = &cobra.Command{
if err != nil {
return err
}
// Utilisation de formatOutput pour formater la réponse
formattedOutput, err := formatOutput(response)
if err != nil {
return err
}

// Affichage de la réponse formatée
fmt.Println(formattedOutput)
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

const (
Version = "1.0.0 beta release" // Définissez ici le numéro de version de votre CLI
Version = "1.1.0 beta release" // Définissez ici le numéro de version de votre CLI
)

var (
Expand Down
Loading

0 comments on commit 726b68d

Please sign in to comment.