github.com/mweagle/Sparta@v1.15.0/aws/step/batch.go (about) 1 package step 2 3 import ( 4 "math/rand" 5 6 gocf "github.com/mweagle/go-cloudformation" 7 ) 8 9 // BatchTaskParameters represents params for the Batch notification 10 // Ref: https://docs.aws.amazon.com/step-functions/latest/dg/connectors-batch.html 11 type BatchTaskParameters struct { 12 JobDefinition gocf.Stringable `json:",omitempty"` 13 JobName string `json:",omitempty"` 14 JobQueue gocf.Stringable `json:",omitempty"` 15 ArrayProperties map[string]interface{} `json:",omitempty"` 16 ContainerOverrides map[string]interface{} `json:",omitempty"` 17 DependsOn []map[string]interface{} `json:",omitempty"` 18 Parameters map[string]string `json:",omitempty"` 19 RetryStrategy map[string]interface{} `json:",omitempty"` 20 Timeout map[string]interface{} `json:",omitempty"` 21 } 22 23 // BatchTaskState represents bindings for 24 // https://docs.aws.amazon.com/step-functions/latest/dg/connectors-batch.html 25 type BatchTaskState struct { 26 BaseTask 27 parameters BatchTaskParameters 28 } 29 30 // MarshalJSON for custom marshalling, since this will be stringified and we need it 31 // to turn into a stringified 32 // Ref: https://docs.aws.amazon.com/step-functions/latest/dg/connectors-batch.html 33 func (bts *BatchTaskState) MarshalJSON() ([]byte, error) { 34 return bts.BaseTask.marshalMergedParams("arn:aws:states:::batch:submitJob.sync", 35 &bts.parameters) 36 } 37 38 // NewBatchTaskState returns an initialized BatchTaskState 39 func NewBatchTaskState(stateName string, 40 parameters BatchTaskParameters) *BatchTaskState { 41 42 sns := &BatchTaskState{ 43 BaseTask: BaseTask{ 44 baseInnerState: baseInnerState{ 45 name: stateName, 46 id: rand.Int63(), 47 }, 48 }, 49 parameters: parameters, 50 } 51 return sns 52 }