func NewBatchClient(awsClient aws.Client,
	getRateLimiter utils.RateLimiter,
	defaultRateLimiter utils.RateLimiter) Client {
	batchClient := batch.New(awsClient.GetSession(), awsClient.GetSdkConfig())
	return NewCustomBatchClient(batchClient, awsClient.GetConfig().AccountID, batchClient.SigningRegion,
		getRateLimiter, defaultRateLimiter)
}
Initializes a new Batch Client that can be used to interact with AWS Batch.
package awsbatch
import (
	"context"
	"fmt"
	definition2 "github.com/flyteorg/flyteplugins/go/tasks/plugins/array/awsbatch/definition"
	"github.com/flyteorg/flyteplugins/go/tasks/aws"
	"github.com/flyteorg/flytestdlib/utils"
	"github.com/flyteorg/flytestdlib/logger"
	a "github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/request"
	"github.com/aws/aws-sdk-go/service/batch"
)
type Client interface {
	SubmitJob(ctx context.Context, input *batch.SubmitJobInput) (jobID string, err error)
	TerminateJob(ctx context.Context, jobID JobID, reason string) error
	GetJobDetailsBatch(ctx context.Context, ids []JobID) ([]*batch.JobDetail, error)
	RegisterJobDefinition(ctx context.Context, name, image, role string) (arn string, err error)
	GetRegion() string
	GetAccountID() string
}
type BatchServiceClient interface {
	SubmitJobWithContext(ctx a.Context, input *batch.SubmitJobInput, opts ...request.Option) (*batch.SubmitJobOutput, error)
	TerminateJobWithContext(ctx a.Context, input *batch.TerminateJobInput, opts ...request.Option) (*batch.TerminateJobOutput, error)
	DescribeJobsWithContext(ctx a.Context, input *batch.DescribeJobsInput, opts ...request.Option) (*batch.DescribeJobsOutput, error)
	RegisterJobDefinitionWithContext(ctx a.Context, input *batch.RegisterJobDefinitionInput, opts ...request.Option) (*batch.RegisterJobDefinitionOutput, error)
}
type client struct {
	Batch              BatchServiceClient
	getRateLimiter     utils.RateLimiter
	defaultRateLimiter utils.RateLimiter
	region             string
	accountID          string
}
func (b client) GetRegion() string {
	return b.region
}
func (b client) GetAccountID() string {
	return b.accountID
}
func (b *client) RegisterJobDefinition(ctx context.Context, name, image, role string) (arn definition2.JobDefinitionArn, err error) {
	logger.Infof(ctx, "Registering job definition with name [%v], image [%v], role [%v]", name, image, role)
	res, err := b.Batch.RegisterJobDefinitionWithContext(ctx, &batch.RegisterJobDefinitionInput{
		Type:              refStr(batch.JobDefinitionTypeContainer),
		JobDefinitionName: refStr(name),
		ContainerProperties: &batch.ContainerProperties{
			Image:      refStr(image),
			JobRoleArn: refStr(role),
			Vcpus:  refInt(1),
			Memory: refInt(100),
		},
	})
	if err != nil {
		return "", err
	}
	return *res.JobDefinitionArn, nil
}
func (b *client) SubmitJob(ctx context.Context, input *batch.SubmitJobInput) (jobID string, err error) {
	if input == nil {
		return "", nil
	}
	if err := b.defaultRateLimiter.Wait(ctx); err != nil {
		return "", err
	}
	output, err := b.Batch.SubmitJobWithContext(ctx, input)
	if err != nil {
		return "", err
	}
	if output.JobId == nil {
		logger.Errorf(ctx, "Job submitted has no ID and no error is returned. This is an AWS-issue. Input [%v]", input.JobName)
		return "", fmt.Errorf("job submitted has no ID and no error is returned. This is an AWS-issue. Input [%v]", input.JobName)
	}
	return *output.JobId, nil
}
func (b *client) TerminateJob(ctx context.Context, jobID JobID, reason string) error {
	if err := b.defaultRateLimiter.Wait(ctx); err != nil {
		return err
	}
	input := batch.TerminateJobInput{
		JobId:  refStr(jobID),
		Reason: refStr(reason),
	}
	if _, err := b.Batch.TerminateJobWithContext(ctx, &input); err != nil {
		return err
	}
	return nil
}
func (b *client) GetJobDetailsBatch(ctx context.Context, jobIds []JobID) ([]*batch.JobDetail, error) {
	if err := b.getRateLimiter.Wait(ctx); err != nil {
		return nil, err
	}
	ids := make([]*string, 0, len(jobIds))
	for _, id := range jobIds {
		ids = append(ids, refStr(id))
	}
	input := batch.DescribeJobsInput{
		Jobs: ids,
	}
	output, err := b.Batch.DescribeJobsWithContext(ctx, &input)
	if err != nil {
		return nil, err
	}
	return output.Jobs, nil
}