Skip to content

Commit 6e12909

Browse files
committed
Replace "folder" with "path" in Share (PAN-8665)
1 parent 9e926b5 commit 6e12909

File tree

10 files changed

+37
-36
lines changed

10 files changed

+37
-36
lines changed

dev/run_examples.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
# Need to run this script from `./examples/` folder
55

66
set -e
7-
skip_items=("/util/", "share/cli.go")
7+
skip_items=(
8+
"/util/"
9+
"share/cli.go"
10+
)
811

912
# Root directory
1013
root_directory=$(pwd)

examples/audit/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ require (
1010
github.com/mattn/go-colorable v0.1.13 // indirect
1111
github.com/mattn/go-isatty v0.0.20 // indirect
1212
github.com/rs/zerolog v1.33.0 // indirect
13-
golang.org/x/crypto v0.24.0 // indirect
14-
golang.org/x/sys v0.21.0 // indirect
13+
golang.org/x/crypto v0.28.0 // indirect
14+
golang.org/x/sys v0.26.0 // indirect
1515
)
1616

1717
replace github.com/pangeacyber/pangea-go/pangea-sdk/v4 v4.0.0 => ../../pangea-sdk

examples/audit/go.sum

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
2424
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
2525
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
2626
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
27-
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
28-
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
27+
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
28+
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
2929
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
3030
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
3131
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
32-
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
33-
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
34-
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
35-
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
32+
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
33+
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
34+
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
35+
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
3636
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
3737
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

examples/share/cli.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func main() {
103103
}
104104
defer f.Close()
105105

106-
uploadResponse, err := client.Put(ctx, &share.PutRequest{Path: fmt.Sprintf("%s/%s", dest, filepath.Base(file))}, f)
106+
uploadResponse, err := client.Put(ctx, &share.PutRequest{Folder: fmt.Sprintf("%s/%s", dest, filepath.Base(file))}, f)
107107
if err != nil {
108108
fmt.Fprintln(os.Stderr, err)
109109
os.Exit(1)

examples/share/folder_create_and_delete.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func main() {
3232

3333
// Create a FolderCreateRequest and set the path of the folder to be created
3434
input := &share.FolderCreateRequest{
35-
Path: path,
35+
Folder: path,
3636
}
3737

3838
fmt.Printf("Let's create a folder: %s\n", path)

examples/share/item_life_cycle.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func main() {
4141

4242
// Create a folder
4343
respCreate, err := client.FolderCreate(ctx, &share.FolderCreateRequest{
44-
Path: folder,
44+
Folder: folder,
4545
})
4646
if err != nil {
4747
log.Fatalf("unexpected error: %v", err)
@@ -59,7 +59,7 @@ func main() {
5959
fmt.Println("Uploading file with Path field...")
6060
respPut, err := client.Put(ctx,
6161
&share.PutRequest{
62-
Path: path.Join(folder, "file_multipart_1"),
62+
Folder: path.Join(folder, "file_multipart_1"),
6363
TransferRequest: pangea.TransferRequest{
6464
TransferMethod: pangea.TMmultipart,
6565
},

go.work.sum

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
2+
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
13
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
4+
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
25
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
6+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=

pangea-sdk/service/share/api.go

+9-14
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ type DeleteRequest struct {
7474

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

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

129128
// @summary Delete
130129
//
131-
// @description Delete object by ID or path. If both are supplied, the path must
132-
// match that of the object represented by the ID.
130+
// @description Delete object by ID.
133131
//
134132
// @operationId store_post_v1_delete
135133
//
@@ -150,7 +148,7 @@ type FolderCreateRequest struct {
150148
Name string `json:"name,omitempty"` // The name of an object.
151149
Metadata Metadata `json:"metadata,omitempty"` // A set of string-based key/value pairs used to provide additional data about an object.
152150
ParentID string `json:"parent_id,omitempty"` // The ID of a stored object.
153-
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.
151+
Folder string `json:"folder,omitempty"` // The folder to place the folder in. Must match `parent_id` if also set.
154152
Tags Tags `json:"tags,omitempty"` // A list of user-defined tags
155153
BucketID *string `json:"bucket_id,omitempty"` // The bucket to use, if not the default.
156154
}
@@ -173,7 +171,7 @@ type FolderCreateResult struct {
173171
// "priority": "medium",
174172
// },
175173
// ParentID: "pos_3djfmzg2db4c6donarecbyv5begtj2bm",
176-
// Path: "/",
174+
// Folder: "/",
177175
// Tags: share.Tags{"irs_2023", "personal"},
178176
// }
179177
//
@@ -186,7 +184,6 @@ type GetRequest struct {
186184
pangea.BaseRequest
187185

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

200197
// @summary Get an object
201198
//
202-
// @description Get object. If both ID and path are supplied, the call will fail
203-
// if the target object doesn't match both properties.
199+
// @description Get object.
204200
//
205201
// @operationId store_post_v1_get
206202
//
207203
// @example
208204
//
209205
// input := &share.GetRequest{
210206
// ID: "pos_3djfmzg2db4c6donarecbyv5begtj2bm",
211-
// Path: "/",
212207
// }
213208
//
214209
// res, err := shareClient.Get(ctx, input)
@@ -230,7 +225,7 @@ type PutRequest struct {
230225
Metadata Metadata `json:"metadata,omitempty"` // A set of string-based key/value pairs used to provide additional data about an object.
231226
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.
232227
ParentID string `json:"parent_id,omitempty"` // The parent ID of the object (a folder). Leave blank to keep in the root folder.
233-
Path string `json:"path,omitempty"` // An optional path where the file should be placed. It will auto-create directories if necessary.
228+
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.
234229
Password string `json:"password,omitempty"` // An optional password to protect the file with. Downloading the file will require this password.
235230
PasswordAlgorithm string `json:"password_algorithm,omitempty"` // An optional password algorithm to protect the file with. See symmetric vault password_algorithm.
236231
SHA1 string `json:"sha1,omitempty"` // The hexadecimal-encoded SHA1 hash of the file data, which will be verified by the server if provided.
@@ -258,7 +253,7 @@ type PutResult struct {
258253
// "priority": "medium",
259254
// },
260255
// ParentID: "pos_3djfmzg2db4c6donarecbyv5begtj2bm",
261-
// Path: "/",
256+
// Folder: "/",
262257
// Tags: share.Tags{"irs_2023", "personal"},
263258
// }
264259
//
@@ -303,7 +298,7 @@ type UpdateRequest struct {
303298
pangea.BaseRequest
304299

305300
ID string `json:"id"` // An identifier for the file to update.
306-
Path string `json:"path,omitempty"` // An alternative to ID for identifying the target file.
301+
Folder string `json:"folder,omitempty"` // Set the parent (folder). Leave blank for the root folder. Path must resolve to `parent_id` if also set.
307302
BucketID *string `json:"bucket_id,omitempty"` // The bucket to use, if not the default.
308303
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.
309304
AddPassword string `json:"add_password,omitempty"` // Protect the file with the supplied password.
@@ -333,7 +328,7 @@ type UpdateResult struct {
333328
//
334329
// input := &share.UpdateRequest{
335330
// ID: "pos_3djfmzg2db4c6donarecbyv5begtj2bm",
336-
// Path: "/",
331+
// Folder: "/",
337332
// RemoveMetadata: share.Metadata{
338333
// "created_by": "jim",
339334
// "priority": "medium",
@@ -720,7 +715,7 @@ func (e *share) ShareLinkDelete(ctx context.Context, input *ShareLinkDeleteReque
720715
// "priority": "medium",
721716
// },
722717
// ParentID: "pos_3djfmzg2db4c6donarecbyv5begtj2bm",
723-
// Path: "/",
718+
// Folder: "/",
724719
// Tags: share.Tags{"irs_2023", "personal"},
725720
// }
726721
//

pangea-sdk/service/share/integration_test.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func Test_Integration_Folder(t *testing.T) {
5555
client := share.New(cfg)
5656

5757
input := &share.FolderCreateRequest{
58-
Path: FOLDER_DELETE,
58+
Folder: FOLDER_DELETE,
5959
}
6060

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

225225
input := &share.PutRequest{
226-
Path: path,
226+
Folder: path,
227227
TransferRequest: pangea.TransferRequest{
228228
TransferMethod: pangea.TMpostURL,
229229
},
@@ -483,7 +483,7 @@ func Test_Integration_LifeCycle(t *testing.T) {
483483

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

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

516516
assert.NotNil(t, respPut)
517517
assert.NotNil(t, respPut.Result)
518-
assert.Equal(t, folderID, respPut.Result.Object.ParentID)
519518
assert.Empty(t, respPut.Result.Object.Metadata)
520519
assert.Empty(t, respPut.Result.Object.Tags)
521-
assert.Empty(t, respPut.Result.Object.MD5)
522-
assert.Empty(t, respPut.Result.Object.SHA512)
520+
assert.NotEmpty(t, respPut.Result.Object.MD5)
521+
assert.NotEmpty(t, respPut.Result.Object.SHA512)
523522
assert.NotEmpty(t, respPut.Result.Object.SHA256)
524523

525524
// Upload a file with parent id and name
@@ -548,8 +547,8 @@ func Test_Integration_LifeCycle(t *testing.T) {
548547
assert.Equal(t, folderID, respPut2.Result.Object.ParentID)
549548
assert.Equal(t, share.Metadata(METADATA), respPut2.Result.Object.Metadata)
550549
assert.Equal(t, share.Tags(TAGS), respPut2.Result.Object.Tags)
551-
assert.Empty(t, respPut2.Result.Object.MD5)
552-
assert.Empty(t, respPut2.Result.Object.SHA512)
550+
assert.NotEmpty(t, respPut2.Result.Object.MD5)
551+
assert.NotEmpty(t, respPut2.Result.Object.SHA512)
553552
assert.NotEmpty(t, respPut2.Result.Object.SHA256)
554553

555554
// Update file with full metadata and tags

0 commit comments

Comments
 (0)