Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for scheduledDeletion #1457

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changelog/1457.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```release-note:enhancement
stream: Add ScheduledDeletion to StreamVideo
```

```release-note:enhancement
stream: Add ScheduledDeletion to StreamUploadFromURLParameters
```

```release-note:enhancement
stream: Add ScheduledDeletion to StreamCreateVideoParameters
```

```release-note:enhancement
stream: Add ScheduledDeletion to StreamVideoCreate
```
17 changes: 11 additions & 6 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type StreamVideo struct {
Creator string `json:"creator,omitempty"`
LiveInput string `json:"liveInput,omitempty"`
Uploaded *time.Time `json:"uploaded,omitempty"`
ScheduledDeletion *time.Time `json:"scheduledDeletion,omitempty"`
Watermark StreamVideoWatermark `json:"watermark,omitempty"`
NFT StreamVideoNFTParameters `json:"nft,omitempty"`
}
Expand Down Expand Up @@ -124,6 +125,7 @@ type StreamUploadFromURLParameters struct {
RequireSignedURLs bool `json:"requireSignedURLs,omitempty"`
Watermark UploadVideoURLWatermark `json:"watermark,omitempty"`
Meta map[string]interface{} `json:"meta,omitempty"`
ScheduledDeletion *time.Time `json:"scheduledDeletion,omitempty"`
}

// StreamCreateVideoParameters are parameters used when creating a video.
Expand All @@ -137,6 +139,7 @@ type StreamCreateVideoParameters struct {
RequireSignedURLs bool `json:"requireSignedURLs,omitempty"`
Watermark UploadVideoURLWatermark `json:"watermark,omitempty"`
Meta map[string]interface{} `json:"meta,omitempty"`
ScheduledDeletion *time.Time `json:"scheduledDeletion,omitempty"`
}

// UploadVideoURLWatermark represents UID of an existing watermark.
Expand All @@ -146,9 +149,10 @@ type UploadVideoURLWatermark struct {

// StreamVideoCreate represents parameters returned after creating a video.
type StreamVideoCreate struct {
UploadURL string `json:"uploadURL,omitempty"`
UID string `json:"uid,omitempty"`
Watermark StreamVideoWatermark `json:"watermark,omitempty"`
UploadURL string `json:"uploadURL,omitempty"`
UID string `json:"uid,omitempty"`
Watermark StreamVideoWatermark `json:"watermark,omitempty"`
ScheduledDeletion *time.Time `json:"scheduledDeletion,omitempty"`
}

// StreamParameters are the basic parameters needed.
Expand All @@ -159,9 +163,10 @@ type StreamParameters struct {

// StreamUploadFileParameters are parameters needed for file upload of a video.
type StreamUploadFileParameters struct {
AccountID string
VideoID string
FilePath string
AccountID string
VideoID string
FilePath string
ScheduledDeletion *time.Time
}

// StreamListParameters represents parameters used when listing stream videos.
Expand Down
41 changes: 34 additions & 7 deletions stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ const (
"nft": {
"contract": "0x57f1887a8bf19b14fc0d912b9b2acc9af147ea85",
"token": 5
}
},
"scheduledDeletion": "2014-01-02T02:20:00Z"
}
}
`
Expand All @@ -85,6 +86,8 @@ func createTestVideo() StreamVideo {
modified, _ := time.Parse(time.RFC3339, "2014-01-02T02:20:00Z")
uploadexpiry, _ := time.Parse(time.RFC3339, "2014-01-02T02:20:00Z")
uploaded, _ := time.Parse(time.RFC3339, "2014-01-02T02:20:00Z")
scheduledDuration, _ := time.Parse(time.RFC3339, "2014-01-02T02:20:00Z")

return StreamVideo{
AllowedOrigins: []string{"example.com"},
Created: &created,
Expand Down Expand Up @@ -130,6 +133,7 @@ func createTestVideo() StreamVideo {
Token: 5,
Contract: "0x57f1887a8bf19b14fc0d912b9b2acc9af147ea85",
},
ScheduledDeletion: &scheduledDuration,
}
}

Expand All @@ -155,13 +159,16 @@ func TestStream_StreamUploadFromURL(t *testing.T) {
assert.Equal(t, ErrMissingUploadURL, err)
}

scheduledDuration, _ := time.Parse(time.RFC3339, "2014-01-02T02:20:00Z")

want := TestVideoStruct
input := StreamUploadFromURLParameters{
AccountID: testAccountID,
URL: "https://example.com/myvideo.mp4",
Meta: map[string]interface{}{
"name": "My First Stream Video",
},
ScheduledDeletion: &scheduledDuration,
}

out, err := client.StreamUploadFromURL(context.Background(), input)
Expand Down Expand Up @@ -192,7 +199,15 @@ func TestStream_UploadVideoFile(t *testing.T) {
assert.Equal(t, ErrMissingFilePath, err)
}

input := StreamUploadFileParameters{AccountID: testAccountID, VideoID: testVideoID, FilePath: "stream_test.go"}
scheduledDuration, _ := time.Parse(time.RFC3339, "2014-01-02T02:20:00Z")

input := StreamUploadFileParameters{
AccountID: testAccountID,
VideoID: testVideoID,
FilePath: "stream_test.go",
ScheduledDeletion: &scheduledDuration,
}

out, err := client.StreamUploadVideoFile(context.Background(), input)

want := TestVideoStruct
Expand Down Expand Up @@ -228,7 +243,8 @@ func TestStream_CreateVideoDirectURL(t *testing.T) {
"padding": 0.1,
"scale": 0.1,
"position": "center"
}
},
"scheduledDeletion": "2014-01-02T02:20:00Z"
}
}
`)
Expand All @@ -248,12 +264,21 @@ func TestStream_CreateVideoDirectURL(t *testing.T) {
assert.Equal(t, ErrMissingMaxDuration, err)
}

input := StreamCreateVideoParameters{AccountID: testAccountID, MaxDurationSeconds: 300, Meta: map[string]interface{}{
"name": "My First Stream Video",
}}
scheduledDuration, _ := time.Parse(time.RFC3339, "2014-01-02T02:20:00Z")

input := StreamCreateVideoParameters{
AccountID: testAccountID,
MaxDurationSeconds: 300,
Meta: map[string]interface{}{
"name": "My First Stream Video",
},
ScheduledDeletion: &scheduledDuration,
}

out, err := client.StreamCreateVideoDirectURL(context.Background(), input)

created, _ := time.Parse(time.RFC3339, "2014-01-02T02:20:00Z")

want := StreamVideoCreate{
UploadURL: "www.example.com/samplepath",
UID: "ea95132c15732412d22c1476fa83f27a",
Expand All @@ -270,6 +295,7 @@ func TestStream_CreateVideoDirectURL(t *testing.T) {
Scale: 0.1,
Position: "center",
},
ScheduledDeletion: &scheduledDuration,
}

if assert.NoError(t, err) {
Expand Down Expand Up @@ -341,7 +367,8 @@ func TestStream_ListVideos(t *testing.T) {
"nft": {
"contract": "0x57f1887a8bf19b14fc0d912b9b2acc9af147ea85",
"token": 5
}
},
"scheduledDeletion": "2014-01-02T02:20:00Z"
}]
}
`)
Expand Down