Skip to content

Commit

Permalink
Replace "folder" with "path" in Share (PAN-8665)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenany committed Oct 16, 2024
1 parent 9e926b5 commit 6e12909
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 36 deletions.
5 changes: 4 additions & 1 deletion dev/run_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
# Need to run this script from `./examples/` folder

set -e
skip_items=("/util/", "share/cli.go")
skip_items=(
"/util/"
"share/cli.go"
)

# Root directory
root_directory=$(pwd)
Expand Down
4 changes: 2 additions & 2 deletions examples/audit/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/rs/zerolog v1.33.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/sys v0.26.0 // indirect
)

replace github.com/pangeacyber/pangea-go/pangea-sdk/v4 v4.0.0 => ../../pangea-sdk
12 changes: 6 additions & 6 deletions examples/audit/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion examples/share/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func main() {
}
defer f.Close()

uploadResponse, err := client.Put(ctx, &share.PutRequest{Path: fmt.Sprintf("%s/%s", dest, filepath.Base(file))}, f)
uploadResponse, err := client.Put(ctx, &share.PutRequest{Folder: fmt.Sprintf("%s/%s", dest, filepath.Base(file))}, f)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion examples/share/folder_create_and_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func main() {

// Create a FolderCreateRequest and set the path of the folder to be created
input := &share.FolderCreateRequest{
Path: path,
Folder: path,
}

fmt.Printf("Let's create a folder: %s\n", path)
Expand Down
4 changes: 2 additions & 2 deletions examples/share/item_life_cycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func main() {

// Create a folder
respCreate, err := client.FolderCreate(ctx, &share.FolderCreateRequest{
Path: folder,
Folder: folder,
})
if err != nil {
log.Fatalf("unexpected error: %v", err)
Expand All @@ -59,7 +59,7 @@ func main() {
fmt.Println("Uploading file with Path field...")
respPut, err := client.Put(ctx,
&share.PutRequest{
Path: path.Join(folder, "file_multipart_1"),
Folder: path.Join(folder, "file_multipart_1"),
TransferRequest: pangea.TransferRequest{
TransferMethod: pangea.TMmultipart,
},
Expand Down
4 changes: 4 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
23 changes: 9 additions & 14 deletions pangea-sdk/service/share/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ type DeleteRequest struct {

ID string `json:"id,omitempty"` // The ID of the object to delete.
Force *bool `json:"force,omitempty"` // If true, delete a folder even if it's not empty. Deletes the contents of folder as well.
Path string `json:"path,omitempty"` // The path of the object to delete.
BucketID *string `json:"bucket_id,omitempty"` // The bucket to use, if not the default.
}

Expand Down Expand Up @@ -128,8 +127,7 @@ func (e *share) Buckets(ctx context.Context) (*pangea.PangeaResponse[BucketsResu

// @summary Delete
//
// @description Delete object by ID or path. If both are supplied, the path must
// match that of the object represented by the ID.
// @description Delete object by ID.
//
// @operationId store_post_v1_delete
//
Expand All @@ -150,7 +148,7 @@ type FolderCreateRequest struct {
Name string `json:"name,omitempty"` // The name of an object.
Metadata Metadata `json:"metadata,omitempty"` // A set of string-based key/value pairs used to provide additional data about an object.
ParentID string `json:"parent_id,omitempty"` // The ID of a stored object.
Path string `json:"path,omitempty"` // An case-sensitive path to an object. Contains a sequence of path segments delimited by the the / character. Any path ending in a / character refers to a folder.
Folder string `json:"folder,omitempty"` // The folder to place the folder in. Must match `parent_id` if also set.
Tags Tags `json:"tags,omitempty"` // A list of user-defined tags
BucketID *string `json:"bucket_id,omitempty"` // The bucket to use, if not the default.
}
Expand All @@ -173,7 +171,7 @@ type FolderCreateResult struct {
// "priority": "medium",
// },
// ParentID: "pos_3djfmzg2db4c6donarecbyv5begtj2bm",
// Path: "/",
// Folder: "/",
// Tags: share.Tags{"irs_2023", "personal"},
// }
//
Expand All @@ -186,7 +184,6 @@ type GetRequest struct {
pangea.BaseRequest

ID string `json:"id,omitempty"` // The ID of the object to retrieve.
Path string `json:"path,omitempty"` // The path of the object to retrieve.
Password *string `json:"password,omitempty"` // If the file was protected with a password, the password to decrypt with.
TransferMethod pangea.TransferMethod `json:"transfer_method,omitempty"` // The requested transfer method for the file data.
BucketID *string `json:"bucket_id,omitempty"` // The bucket to use, if not the default.
Expand All @@ -199,16 +196,14 @@ type GetResult struct {

// @summary Get an object
//
// @description Get object. If both ID and path are supplied, the call will fail
// if the target object doesn't match both properties.
// @description Get object.
//
// @operationId store_post_v1_get
//
// @example
//
// input := &share.GetRequest{
// ID: "pos_3djfmzg2db4c6donarecbyv5begtj2bm",
// Path: "/",
// }
//
// res, err := shareClient.Get(ctx, input)
Expand All @@ -230,7 +225,7 @@ type PutRequest struct {
Metadata Metadata `json:"metadata,omitempty"` // A set of string-based key/value pairs used to provide additional data about an object.
MimeType string `json:"mimetype,omitempty"` // The MIME type of the file, which will be verified by the server if provided. Uploads not matching the supplied MIME type will be rejected.
ParentID string `json:"parent_id,omitempty"` // The parent ID of the object (a folder). Leave blank to keep in the root folder.
Path string `json:"path,omitempty"` // An optional path where the file should be placed. It will auto-create directories if necessary.
Folder string `json:"folder,omitempty"` // The path to the parent folder. Leave blank for the root folder. Path must resolve to `parent_id` if also set.
Password string `json:"password,omitempty"` // An optional password to protect the file with. Downloading the file will require this password.
PasswordAlgorithm string `json:"password_algorithm,omitempty"` // An optional password algorithm to protect the file with. See symmetric vault password_algorithm.
SHA1 string `json:"sha1,omitempty"` // The hexadecimal-encoded SHA1 hash of the file data, which will be verified by the server if provided.
Expand Down Expand Up @@ -258,7 +253,7 @@ type PutResult struct {
// "priority": "medium",
// },
// ParentID: "pos_3djfmzg2db4c6donarecbyv5begtj2bm",
// Path: "/",
// Folder: "/",
// Tags: share.Tags{"irs_2023", "personal"},
// }
//
Expand Down Expand Up @@ -303,7 +298,7 @@ type UpdateRequest struct {
pangea.BaseRequest

ID string `json:"id"` // An identifier for the file to update.
Path string `json:"path,omitempty"` // An alternative to ID for identifying the target file.
Folder string `json:"folder,omitempty"` // Set the parent (folder). Leave blank for the root folder. Path must resolve to `parent_id` if also set.
BucketID *string `json:"bucket_id,omitempty"` // The bucket to use, if not the default.
AddMetadata Metadata `json:"add_metadata,omitempty"` // A list of Metadata key/values to set in the object. If a provided key exists, the value will be replaced.
AddPassword string `json:"add_password,omitempty"` // Protect the file with the supplied password.
Expand Down Expand Up @@ -333,7 +328,7 @@ type UpdateResult struct {
//
// input := &share.UpdateRequest{
// ID: "pos_3djfmzg2db4c6donarecbyv5begtj2bm",
// Path: "/",
// Folder: "/",
// RemoveMetadata: share.Metadata{
// "created_by": "jim",
// "priority": "medium",
Expand Down Expand Up @@ -720,7 +715,7 @@ func (e *share) ShareLinkDelete(ctx context.Context, input *ShareLinkDeleteReque
// "priority": "medium",
// },
// ParentID: "pos_3djfmzg2db4c6donarecbyv5begtj2bm",
// Path: "/",
// Folder: "/",
// Tags: share.Tags{"irs_2023", "personal"},
// }
//
Expand Down
17 changes: 8 additions & 9 deletions pangea-sdk/service/share/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func Test_Integration_Folder(t *testing.T) {
client := share.New(cfg)

input := &share.FolderCreateRequest{
Path: FOLDER_DELETE,
Folder: FOLDER_DELETE,
}

out, err := client.FolderCreate(ctx, input)
Expand Down Expand Up @@ -223,7 +223,7 @@ func Test_Integration_PutTransferMethodPostURL_PathAnd18MB(t *testing.T) {
path := "/sdk/tests/go/" + TIME + "_file_post_url"

input := &share.PutRequest{
Path: path,
Folder: path,
TransferRequest: pangea.TransferRequest{
TransferMethod: pangea.TMpostURL,
},
Expand Down Expand Up @@ -483,7 +483,7 @@ func Test_Integration_LifeCycle(t *testing.T) {

// Create a folder
respCreate, err := client.FolderCreate(ctx, &share.FolderCreateRequest{
Path: FOLDER_FILES,
Folder: FOLDER_FILES,
})
if err != nil {
t.Fatalf("unexpected error: %v", err)
Expand All @@ -502,7 +502,7 @@ func Test_Integration_LifeCycle(t *testing.T) {

respPut, err := client.Put(ctx,
&share.PutRequest{
Path: FOLDER_FILES + "/" + TIME + "_file_multipart_1",
Folder: FOLDER_FILES + "/" + TIME + "_file_multipart_1",
TransferRequest: pangea.TransferRequest{
TransferMethod: pangea.TMmultipart,
},
Expand All @@ -515,11 +515,10 @@ func Test_Integration_LifeCycle(t *testing.T) {

assert.NotNil(t, respPut)
assert.NotNil(t, respPut.Result)
assert.Equal(t, folderID, respPut.Result.Object.ParentID)
assert.Empty(t, respPut.Result.Object.Metadata)
assert.Empty(t, respPut.Result.Object.Tags)
assert.Empty(t, respPut.Result.Object.MD5)
assert.Empty(t, respPut.Result.Object.SHA512)
assert.NotEmpty(t, respPut.Result.Object.MD5)
assert.NotEmpty(t, respPut.Result.Object.SHA512)
assert.NotEmpty(t, respPut.Result.Object.SHA256)

// Upload a file with parent id and name
Expand Down Expand Up @@ -548,8 +547,8 @@ func Test_Integration_LifeCycle(t *testing.T) {
assert.Equal(t, folderID, respPut2.Result.Object.ParentID)
assert.Equal(t, share.Metadata(METADATA), respPut2.Result.Object.Metadata)
assert.Equal(t, share.Tags(TAGS), respPut2.Result.Object.Tags)
assert.Empty(t, respPut2.Result.Object.MD5)
assert.Empty(t, respPut2.Result.Object.SHA512)
assert.NotEmpty(t, respPut2.Result.Object.MD5)
assert.NotEmpty(t, respPut2.Result.Object.SHA512)
assert.NotEmpty(t, respPut2.Result.Object.SHA256)

// Update file with full metadata and tags
Expand Down
File renamed without changes.

0 comments on commit 6e12909

Please sign in to comment.