@@ -8,16 +8,14 @@ package file
8
8
9
9
import (
10
10
"errors"
11
- "github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
11
+ "io"
12
+ "reflect"
13
+
12
14
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"
13
15
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/exported"
14
16
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/generated"
15
17
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/path"
16
18
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/shared"
17
- "io"
18
- "net/http"
19
- "strconv"
20
- "time"
21
19
)
22
20
23
21
const (
@@ -42,7 +40,7 @@ type CreateOptions struct {
42
40
// HTTPHeaders contains the HTTP headers for path operations.
43
41
HTTPHeaders * HTTPHeaders
44
42
// Expiry specifies the type and time of expiry for the file.
45
- Expiry CreationExpiryType
43
+ Expiry CreateExpiryValues
46
44
// LeaseDuration specifies the duration of the lease, in seconds, or negative one
47
45
// (-1) for a lease that never expires. A non-infinite lease can be
48
46
// between 15 and 60 seconds.
@@ -61,6 +59,18 @@ type CreateOptions struct {
61
59
ACL * string
62
60
}
63
61
62
+ // CreateExpiryValues describes when a newly created file should expire.
63
+ // A zero-value indicates the file has no expiration date.
64
+ type CreateExpiryValues struct {
65
+ // ExpiryType indicates how the value of ExpiresOn should be interpreted (absolute, relative to now, etc).
66
+ ExpiryType CreateExpiryType
67
+
68
+ // ExpiresOn contains the time the file should expire.
69
+ // The value will either be an absolute UTC time in RFC1123 format or an integer expressing a number of milliseconds.
70
+ // NOTE: when ExpiryType is CreateExpiryTypeNeverExpire, this value is ignored.
71
+ ExpiresOn string
72
+ }
73
+
64
74
func (o * CreateOptions ) format () (* generated.LeaseAccessConditions , * generated.ModifiedAccessConditions , * generated.PathHTTPHeaders , * generated.PathClientCreateOptions , * generated.CPKInfo ) {
65
75
resource := generated .PathResourceTypeFile
66
76
createOpts := & generated.PathClientCreateOptions {
@@ -70,13 +80,11 @@ func (o *CreateOptions) format() (*generated.LeaseAccessConditions, *generated.M
70
80
return nil , nil , nil , createOpts , nil
71
81
}
72
82
leaseAccessConditions , modifiedAccessConditions := exported .FormatPathAccessConditions (o .AccessConditions )
73
- if o .Expiry == nil {
74
- createOpts .ExpiryOptions = nil
75
- createOpts .ExpiresOn = nil
76
- } else {
77
- expOpts , expiresOn := o .Expiry .Format ()
78
- createOpts .ExpiryOptions = (* generated .PathExpiryOptions )(& expOpts )
79
- createOpts .ExpiresOn = expiresOn
83
+ if ! reflect .ValueOf (o .Expiry ).IsZero () {
84
+ createOpts .ExpiryOptions = & o .Expiry .ExpiryType
85
+ if o .Expiry .ExpiryType != CreateExpiryTypeNeverExpire {
86
+ createOpts .ExpiresOn = & o .Expiry .ExpiresOn
87
+ }
80
88
}
81
89
createOpts .ACL = o .ACL
82
90
createOpts .Group = o .Group
@@ -491,65 +499,28 @@ func (o *DownloadFileOptions) format() *blob.DownloadFileOptions {
491
499
return downloadFileOptions
492
500
}
493
501
494
- // CreationExpiryType defines values for Create() ExpiryType
495
- type CreationExpiryType interface {
496
- Format () (generated.ExpiryOptions , * string )
497
- notPubliclyImplementable ()
498
- }
499
-
500
- // CreationExpiryTypeAbsolute defines the absolute time for the blob expiry
501
- type CreationExpiryTypeAbsolute time.Time
502
-
503
- // CreationExpiryTypeRelativeToNow defines the duration relative to now for the blob expiry
504
- type CreationExpiryTypeRelativeToNow time.Duration
505
-
506
- // CreationExpiryTypeNever defines that the blob will be set to never expire
507
- type CreationExpiryTypeNever struct {
508
- // empty struct since NeverExpire expiry type does not require expiry time
509
- }
510
-
511
- func (e CreationExpiryTypeAbsolute ) Format () (generated.ExpiryOptions , * string ) {
512
- return generated .ExpiryOptionsAbsolute , to .Ptr (time .Time (e ).UTC ().Format (http .TimeFormat ))
502
+ // SetExpiryValues describes when a file should expire.
503
+ // A zero-value indicates the file has no expiration date.
504
+ type SetExpiryValues struct {
505
+ // ExpiryType indicates how the value of ExpiresOn should be interpreted (absolute, relative to now, etc).
506
+ ExpiryType SetExpiryType
513
507
508
+ // ExpiresOn contains the time the file should expire.
509
+ // The value will either be an absolute UTC time in RFC1123 format or an integer expressing a number of milliseconds.
510
+ // NOTE: when ExpiryType is SetExpiryTypeNeverExpire, this value is ignored.
511
+ ExpiresOn string
514
512
}
515
513
516
- func (e CreationExpiryTypeAbsolute ) notPubliclyImplementable () {}
517
-
518
- func (e CreationExpiryTypeRelativeToNow ) Format () (generated.ExpiryOptions , * string ) {
519
- return generated .ExpiryOptionsRelativeToNow , to .Ptr (strconv .FormatInt (time .Duration (e ).Milliseconds (), 10 ))
520
- }
521
-
522
- func (e CreationExpiryTypeRelativeToNow ) notPubliclyImplementable () {}
523
-
524
- func (e CreationExpiryTypeNever ) Format () (generated.ExpiryOptions , * string ) {
525
- return generated .ExpiryOptionsNeverExpire , nil
526
- }
527
-
528
- func (e CreationExpiryTypeNever ) notPubliclyImplementable () {}
529
-
530
514
// ACLFailedEntry contains the failed ACL entry (response model).
531
515
type ACLFailedEntry = path.ACLFailedEntry
532
516
533
517
// SetAccessControlRecursiveResponse contains part of the response data returned by the []OP_AccessControl operations.
534
518
type SetAccessControlRecursiveResponse = generated.SetAccessControlRecursiveResponse
535
519
536
- // SetExpiryType defines values for ExpiryType.
537
- type SetExpiryType = exported.SetExpiryType
538
-
539
- // SetExpiryTypeAbsolute defines the absolute time for the expiry.
540
- type SetExpiryTypeAbsolute = exported.SetExpiryTypeAbsolute
541
-
542
- // SetExpiryTypeRelativeToNow defines the duration relative to now for the expiry.
543
- type SetExpiryTypeRelativeToNow = exported.SetExpiryTypeRelativeToNow
544
-
545
- // SetExpiryTypeRelativeToCreation defines the duration relative to creation for the expiry.
546
- type SetExpiryTypeRelativeToCreation = exported.SetExpiryTypeRelativeToCreation
547
-
548
- // SetExpiryTypeNever defines that will be set to never expire.
549
- type SetExpiryTypeNever = exported.SetExpiryTypeNever
550
-
551
520
// SetExpiryOptions contains the optional parameters for the Client.SetExpiry method.
552
- type SetExpiryOptions = exported.SetExpiryOptions
521
+ type SetExpiryOptions struct {
522
+ // placeholder for future options
523
+ }
553
524
554
525
type HTTPRange = exported.HTTPRange
555
526
0 commit comments