From 92a0670889fac791ad0fea3bd84e68fe31f3a057 Mon Sep 17 00:00:00 2001 From: Manohar Reddy Date: Wed, 11 Jan 2023 16:01:58 +0100 Subject: [PATCH] clean up: collab command --- README.md | 40 ++-------------- cmd/collaborators.go | 107 ------------------------------------------- 2 files changed, 4 insertions(+), 143 deletions(-) delete mode 100644 cmd/collaborators.go diff --git a/README.md b/README.md index de1ed8ba..56880dfd 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,6 @@ zbox is a command line interface (CLI) tool to understand the capabilities of 0C - [Stats](#stats) - [Repair](#repair) - [Add collaborator](#add-collaborator) - - [Delete collaborator](#delete-collaborator) - [Sign data](#sign-data) - [Streaming](#streaming) - [How it works:](#how-it-works) @@ -125,7 +124,6 @@ When you run the `zbox` command in terminal with no arguments, it will list all [copy](#copy)|copy an object(file/folder) to another folder on blobbers [cp-info](#challenge-pool-information)|Challenge pool information. [delete](#delete)|delete file from blobbers -[delete-collab](#delete-collaborator)|delete collaborator for a file [download](#download)|download file from blobbers [get](#get)|Gets the allocation info [get-diff](#get-differences)|Get difference of local and allocation root @@ -1495,36 +1493,6 @@ Collaborator d477d12134c2d7ba5ab71ac8ad37f244224695ef3215be990c3215d531c5a329 ad You can check all collaborators for a file in metadata json response. -#### Delete collaborator - -Use command delete-collab to remove a collaborator for a file - -| Parameter | Required | Description | default | Valid values | -|------------|----------|------------------------------|---------|--------------| -| allocation | yes | allocation id | | string | -| collabid | yes | id of collaberator | | string | -| remotepath | yes | file on which to collaberate | | string | - -
- delete-collab - -![image](https://user-images.githubusercontent.com/6240686/124505356-3571a900-ddc1-11eb-9dd8-72927cefa790.png) - -
- -Example - -``` -./zbox delete-collab --allocation 8695b9e7f986d4a447b64de020ba86f53b3b5e2c442abceb6cd65742702067dc --remotepath /1.txt --collabid d477d12134c2d7ba5ab71ac8ad37f244224695ef3215be990c3215d531c5a329 -``` - -Response will be a confirmation that collaborator is removed on all blobbers for the given file. - -``` -Collaborator d477d12134c2d7ba5ab71ac8ad37f244224695ef3215be990c3215d531c5a329 removed successfully for the file /1.txt -``` - - #### Sign data `sign-data` uses the information from your wallet to sign the input data string @@ -1776,10 +1744,10 @@ Use `sp-info` to get your stake pool information and settings. #### Lock tokens into stake pool -Lock creates delegate pool for current client and a given provider (blobber or validator). -The tokens locked for the provider stake can be unlocked any time, excluding times -when the tokens held by opened offers. These tokens will earn rewards depending on the -actions of the linked provider. +Lock creates delegate pool for current client and a given provider (blobber or validator). +The tokens locked for the provider stake can be unlocked any time, excluding times +when the tokens held by opened offers. These tokens will earn rewards depending on the +actions of the linked provider. `sp-lock` returns the id of the new stake pool, this will be needed to reference to stake pool later. diff --git a/cmd/collaborators.go b/cmd/collaborators.go deleted file mode 100644 index 0656cc52..00000000 --- a/cmd/collaborators.go +++ /dev/null @@ -1,107 +0,0 @@ -package cmd - -import ( - "fmt" - "os" - - "github.com/0chain/gosdk/zboxcore/sdk" - "github.com/spf13/cobra" -) - -var addCollabCmd = &cobra.Command{ - Use: "add-collab", - Short: "add collaborator for a file", - Long: `add collaborator for a file`, - Args: cobra.MinimumNArgs(0), - Run: func(cmd *cobra.Command, args []string) { - allocationID := cmd.Flag("allocation").Value.String() - if len(allocationID) == 0 { - PrintError("Error: allocation flag is missing") - os.Exit(1) - } - - remotepath := cmd.Flag("remotepath").Value.String() - if len(remotepath) == 0 { - PrintError("Error: remotepath flag is missing") - os.Exit(1) - } - - collabID := cmd.Flag("collabid").Value.String() - if len(collabID) == 0 { - PrintError("Error: collabid flag is missing") - os.Exit(1) - } - - allocationObj, err := sdk.GetAllocation(allocationID) - if err != nil { - PrintError("Error fetching the allocation", err) - os.Exit(1) - } - - err = allocationObj.AddCollaborator(remotepath, collabID) - if err != nil { - PrintError(err.Error()) - os.Exit(1) - } - fmt.Printf("Collaborator %s added successfully for the file %s \n", collabID, remotepath) - return - }, -} - -var deleteCollabCmd = &cobra.Command{ - Use: "delete-collab", - Short: "delete collaborator for a file", - Long: `delete collaborator for a file`, - Args: cobra.MinimumNArgs(0), - Run: func(cmd *cobra.Command, args []string) { - allocationID := cmd.Flag("allocation").Value.String() - if len(allocationID) == 0 { - PrintError("Error: allocation flag is missing") - os.Exit(1) - } - - remotepath := cmd.Flag("remotepath").Value.String() - if len(remotepath) == 0 { - PrintError("Error: remotepath flag is missing") - os.Exit(1) - } - - collabID := cmd.Flag("collabid").Value.String() - if len(collabID) == 0 { - PrintError("Error: collabid flag is missing") - os.Exit(1) - } - - allocationObj, err := sdk.GetAllocation(allocationID) - if err != nil { - PrintError("Error fetching the allocation", err) - os.Exit(1) - } - - err = allocationObj.RemoveCollaborator(remotepath, collabID) - if err != nil { - PrintError(err.Error()) - os.Exit(1) - } - fmt.Printf("Collaborator %s removed successfully for the file %s \n", collabID, remotepath) - return - }, -} - -func init() { - rootCmd.AddCommand(addCollabCmd) - addCollabCmd.PersistentFlags().String("allocation", "", "Allocation ID") - addCollabCmd.PersistentFlags().String("remotepath", "", "Remote path to list from") - addCollabCmd.PersistentFlags().String("collabid", "", "Collaborator's clientID") - addCollabCmd.MarkFlagRequired("allocation") - addCollabCmd.MarkFlagRequired("remotepath") - addCollabCmd.MarkFlagRequired("collabid") - - rootCmd.AddCommand(deleteCollabCmd) - deleteCollabCmd.PersistentFlags().String("allocation", "", "Allocation ID") - deleteCollabCmd.PersistentFlags().String("remotepath", "", "Remote path to list from") - deleteCollabCmd.PersistentFlags().String("collabid", "", "Collaborator's clientID") - deleteCollabCmd.MarkFlagRequired("allocation") - deleteCollabCmd.MarkFlagRequired("remotepath") - deleteCollabCmd.MarkFlagRequired("collabid") -}