cmd

package
v0.0.0-...-23ce5c3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ListRoleCmd = &cobra.Command{
	Use:   "ls",
	Short: "List roles",
	Run: func(cmd *cobra.Command, args []string) {

		httpClient := config.GetHttpClient(config.DefaultConfig)
		apiClient, ctx, err := config.GetPreparedApiClient(config.DefaultConfig)
		if err != nil {
			log.Fatal(err)
		}

		format := "json"

		params := &provisioning.GetRolesParams{
			Context:    ctx,
			HTTPClient: httpClient,
			Format:     &format,
		}

		result, err := apiClient.Provisioning.GetRoles(params, nil)
		if err != nil {
			fmt.Printf("could not list roles: %s\n", err.Error())
			log.Fatal(err)
		}

		count := 1
		for key, node := range result.Payload.Data.Children {
			fmt.Printf("%d. %s - %v\n", count, key, node)
			count = count + 1
		}
	},
}
View Source
var ListSharesCmd = &cobra.Command{
	Use:   "ls",
	Short: "List shares",
	Run: func(cmd *cobra.Command, args []string) {

		shares.SetConfig(config.DefaultConfig)

		allShares, ignored, err := shares.LoadShares()
		if err != nil {
			log.Fatal(err)
		}
		log.Println(fmt.Sprintf("Found %d shares", len(allShares)))
		if len(ignored) > 0 {
			for _, i := range ignored {
				log.Println("Ignored: " + i.Error())
			}
		}
		if !sharesListDetails {
			return
		}
		for _, s := range allShares {
			fmt.Println("")
			if e := s.LoadElement(); e != nil {
				fmt.Println("[ERROR] Cannot load ShareElement: ", e)
				continue
			}

			links := s.GetElement().GetLinks()
			if len(links) > 0 {
				fmt.Println("Share has links: ")
				for _, link := range links {
					fmt.Println("-- " + link.PublicLink)
				}
			}

			sharedUsers := s.GetSharedUsers()
			if len(sharedUsers) > 0 {
				fmt.Printf("Share has %d shared users: %s\n", len(sharedUsers), strings.Join(s.GetSharedUsersIds(), ","))
			}

			if fullPath, ws, ownerId, e := shares.RecurseParentPaths(allShares, s); e == nil {
				fmt.Printf("Full Node Path is %s:/%s [top owner:%s]\n", ws.Slug, fullPath, ownerId)
			} else {
				fmt.Println("[ERROR] Cannot rebuild full path: ", e)
			}
		}
	},
}
View Source
var ListUserCmd = &cobra.Command{
	Use:   "ls",
	Short: "List users",
	Run: func(cmd *cobra.Command, args []string) {

		if err := getUsersFromPath(""); err != nil {
			log.Fatal(err)
		}
	},
}
View Source
var ListWsCmd = &cobra.Command{
	Use:   "ls",
	Short: "List workspaces",
	Run: func(cmd *cobra.Command, args []string) {

		if err := getWorkspaces(); err != nil {
			log.Fatal(err)
		}
	},
}
View Source
var RoleCmd = &cobra.Command{
	Use:   "role",
	Short: "Role-related commands",
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}
View Source
var RootCmd = &cobra.Command{
	Use:   os.Args[0],
	Short: "Rest Client of Pydio Cells",
	Long:  `Pydio Cells client for managing API`,
	PersistentPreRun: func(cmd *cobra.Command, args []string) {

		if host != "" && user != "" && pwd != "" {
			config.DefaultConfig = &config.SdkConfig{
				Protocol:   protocol,
				Url:        host,
				Path:       path,
				User:       user,
				Password:   pwd,
				SkipVerify: skipVerify,
			}
			return
		}

		if configFile == "" {
			log.Fatal("Please provide a path to the configuration file")
		}
		if data, e := ioutil.ReadFile(configFile); e == nil {
			var c config.SdkConfig
			if e := json.Unmarshal(data, &c); e != nil {
				log.Fatal("Cannot decode config content", e)
			}
			config.DefaultConfig = &c
			fmt.Println("Connecting to " + config.DefaultConfig.Url)
			fmt.Println("")
		} else {
			log.Fatal("Cannot read file ", e)
		}

	},
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}
View Source
var SharesCmd = &cobra.Command{
	Use:   "share",
	Short: "Shares-related commands",
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}
View Source
var TwickCmd = &cobra.Command{
	Use:   "twick-model",
	Short: "Modify go-swagger generated models to enable communication with the protobuf generated RESTful API",
	Run: func(cmd *cobra.Command, args []string) {

		err := filepath.Walk("./models", utils.AdaptGeneratedModels)
		if err != nil {
			cmd.Print("could not modify models: " + err.Error())
			return
		}

		cmd.Print("Success: files have been modified")
	},
}
View Source
var UserCmd = &cobra.Command{
	Use:   "user",
	Short: "User-related commands",
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}
View Source
var WorkspacesCmd = &cobra.Command{
	Use:   "ws",
	Short: "Workspaces-related commands",
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL