From 4e2b3947b3d004a380725d7abda1ee34fd57158b Mon Sep 17 00:00:00 2001 From: Samuel Lorch Date: Mon, 30 Aug 2021 20:00:44 +0200 Subject: [PATCH] added Moving and Other Examples --- README.md | 15 +++++++++++++++ helper/folder.go | 2 +- helper/resources.go | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c13dd1d..8030980 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,18 @@ err := helper.ShareResource(ctx, c, resourceID, changes) Note: These Functions are Also Availabe for Folders (PRO) +## Moveing (PRO) +In Passbolt PRO there are Folders, during Creation of Resources and Folders you can Specify in which Folder you want to create the Resource / Folder inside of. But if you want to change which Folder the Resource / Folder is in then you can't use the Update function (it is / was possible to update the parent Folder using the Update function but that breaks things). Instead you use the Move function. +``` +err := client.MoveResource(ctx, "resource id", "parent folder id") +``` +``` +err := client.MoveFolder(ctx, "folder id", "parent folder id") +``` + +## Other +These Examples are just the main Usecases of this Modules, there are many more API calls that are supported. Look at the [Reference](https://pkg.go.dev/github.com/speatzle/go-passbolt) for more information. + ## Full Example This Example Creates a Resource, Searches for a User Named Test User, Checks that its Not itself and Shares the Password with the Test User if Nessesary: @@ -301,6 +313,7 @@ func main() { if client.GetUserID() == users[0].ID { fmt.Println("I am the Test User, No Need to Share Password With myself") + client.Logout(ctx) return } @@ -309,6 +322,8 @@ func main() { panic(err) } fmt.Printf("Shared Resource With Test User %v\n", users[0].ID) + + client.Logout(ctx) } ``` diff --git a/helper/folder.go b/helper/folder.go index 33895cd..670ad9e 100644 --- a/helper/folder.go +++ b/helper/folder.go @@ -32,7 +32,7 @@ func DeleteFolder(ctx context.Context, c *api.Client, folderID string) error { return c.DeleteFolder(ctx, folderID) } -// MoveFolder Moves a Folder into a Folder +// MoveFolder Moves a Folder into a func MoveFolder(ctx context.Context, c *api.Client, folderID, folderParentID string) error { return c.MoveFolder(ctx, folderID, folderParentID) } diff --git a/helper/resources.go b/helper/resources.go index 248b487..8ddcff9 100644 --- a/helper/resources.go +++ b/helper/resources.go @@ -204,7 +204,7 @@ func DeleteResource(ctx context.Context, c *api.Client, resourceID string) error return c.DeleteResource(ctx, resourceID) } -// MoveResource Moves a Resource into a Folder +// MoveResource Moves a Resource into a func MoveResource(ctx context.Context, c *api.Client, resourceID, folderParentID string) error { return c.MoveResource(ctx, resourceID, folderParentID) }