Skip to content

Commit

Permalink
Split into S3BatchJobV2
Browse files Browse the repository at this point in the history
  • Loading branch information
lyoung-confluent committed Jan 27, 2024
1 parent 64a0c9e commit b94adbe
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
28 changes: 24 additions & 4 deletions events/s3_batch_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,37 @@ type S3BatchJobEvent struct {

// S3BatchJob whichs have the job id
type S3BatchJob struct {
ID string `json:"id"`
UserArguments map[string]string `json:"userArguments,omitempty"`
ID string `json:"id"`
}

// S3BatchJobTask represents one task in the s3 batch job and have all task details
type S3BatchJobTask struct {
TaskID string `json:"taskId"`
S3Key string `json:"s3Key"`
S3VersionID string `json:"s3VersionId"`
S3Bucket string `json:"s3Bucket,omitempty"`
S3BucketARN string `json:"s3BucketArn,omitempty"`
S3BucketARN string `json:"s3BucketArn"`
}

// S3BatchJobEventV2 encapsulates the detail of a s3 batch job
type S3BatchJobEventV2 struct {
InvocationSchemaVersion string `json:"invocationSchemaVersion"`
InvocationID string `json:"invocationId"`
Job S3BatchJobV2 `json:"job"`
Tasks []S3BatchJobTaskV2 `json:"tasks"`
}

// S3BatchJobV2 whichs have the job id
type S3BatchJobV2 struct {
ID string `json:"id"`
UserArguments map[string]string `json:"userArguments"`
}

// S3BatchJobTaskV2 represents one task in the s3 batch job and have all task details
type S3BatchJobTaskV2 struct {
TaskID string `json:"taskId"`
S3Key string `json:"s3Key"`
S3VersionID string `json:"s3VersionId"`
S3Bucket string `json:"s3Bucket"`
}

// S3BatchJobResponse is the response of a iven s3 batch job with the results
Expand Down
6 changes: 3 additions & 3 deletions events/s3_batch_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/assert"
)

func TestS3BatchJobEventMarshalingSchema1(t *testing.T) {
func TestS3BatchJobEventMarshaling(t *testing.T) {

// 1. read JSON from file
inputJSON := test.ReadJSONFromFile(t, "./testdata/s3-batch-job-event-request-1.0.json")
Expand All @@ -31,12 +31,12 @@ func TestS3BatchJobEventMarshalingSchema1(t *testing.T) {
assert.JSONEq(t, string(inputJSON), string(outputJSON))
}

func TestS3BatchJobEventMarshalingSchema2(t *testing.T) {
func TestS3BatchJobEventV2Marshaling(t *testing.T) {
// 1. read JSON from file
inputJSON := test.ReadJSONFromFile(t, "./testdata/s3-batch-job-event-request-2.0.json")

// 2. de-serialize into Go object
var inputEvent S3BatchJobEvent
var inputEvent S3BatchJobEventV2
if err := json.Unmarshal(inputJSON, &inputEvent); err != nil {
t.Errorf("could not unmarshal event. details: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions events/testdata/s3-batch-job-event-request-2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"tasks": [
{
"taskId": "dGFza2lkZ29lc2hlcmUK",
"s3Key": "prefix/dataset/dataset.20231222.json.gz",
"s3VersionId": "1",
"s3Bucket": "powertools-dataset"
"s3Key": "customerImage1.jpg",
"s3VersionId": "jbo9_jhdPEyB4RrmOxWS0kU0EoNrU_oI",
"s3Bucket": "awsexamplebucket"
}
]
}

0 comments on commit b94adbe

Please sign in to comment.