Skip to content

Commit

Permalink
Rename S3BucketObject to S3Object
Browse files Browse the repository at this point in the history
  • Loading branch information
nao1215 committed Jan 2, 2024
1 parent 90c48e6 commit 1208623
Show file tree
Hide file tree
Showing 8 changed files with 283 additions and 171 deletions.
44 changes: 28 additions & 16 deletions app/di/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ type S3App struct {
usecase.S3BucketLister
// S3BucketDeleter is the usecase for deleting a S3 bucket.
usecase.S3BucketDeleter
// S3BucketObjectsLister is the usecase for listing S3 bucket objects.
usecase.S3BucketObjectsLister
// S3BucketObjectsDeleter is the usecase for deleting S3 bucket objects.
usecase.S3BucketObjectsDeleter
// S3ObjectsLister is the usecase for listing S3 bucket objects.
usecase.S3ObjectsLister
// S3ObjectsDeleter is the usecase for deleting S3 bucket objects.
usecase.S3ObjectsDeleter
// S3ObjectUploader is the usecase for uploading a file to S3 bucket.
usecase.S3ObjectDownloader
// FileUploader is the usecase for uploading a file.
usecase.FileUploader
}

// NewS3App creates a new S3App.
Expand All @@ -37,13 +41,17 @@ func NewS3App(ctx context.Context, profile model.AWSProfile, region model.Region
external.S3BucketListerSet,
external.S3BucketLocationGetterSet,
external.S3BucketDeleterSet,
external.S3BucketObjectsListerSet,
external.S3BucketObjectsDeleterSet,
external.S3ObjectsListerSet,
external.S3ObjectsDeleterSet,
external.S3ObjectDownloaderSet,
external.S3ObjectUploaderSet,
interactor.S3BucketCreatorSet,
interactor.S3BucketListerSet,
interactor.S3BucketDeleterSet,
interactor.S3BucketObjectsListerSet,
interactor.S3BucketObjectsDeleterSet,
interactor.S3ObjectsListerSet,
interactor.S3ObjectsDeleterSet,
interactor.S3ObjectDownloaderSet,
interactor.FileUploaderSet,
newS3App,
)
return nil, nil
Expand All @@ -53,15 +61,19 @@ func newS3App(
s3BucketCreator usecase.S3BucketCreator,
s3BucketLister usecase.S3BucketLister,
s3BucketDeleter usecase.S3BucketDeleter,
s3BucketObjectsLister usecase.S3BucketObjectsLister,
s3BucketObjectsDeleter usecase.S3BucketObjectsDeleter,
S3ObjectsLister usecase.S3ObjectsLister,
S3ObjectsDeleter usecase.S3ObjectsDeleter,
s3ObjectDownloader usecase.S3ObjectDownloader,
fileUploader usecase.FileUploader,
) *S3App {
return &S3App{
S3BucketCreator: s3BucketCreator,
S3BucketLister: s3BucketLister,
S3BucketDeleter: s3BucketDeleter,
S3BucketObjectsLister: s3BucketObjectsLister,
S3BucketObjectsDeleter: s3BucketObjectsDeleter,
S3BucketCreator: s3BucketCreator,
S3BucketLister: s3BucketLister,
S3BucketDeleter: s3BucketDeleter,
S3ObjectsLister: S3ObjectsLister,
S3ObjectsDeleter: S3ObjectsDeleter,
S3ObjectDownloader: s3ObjectDownloader,
FileUploader: fileUploader,
}
}

Expand All @@ -88,7 +100,7 @@ func NewSpareApp(ctx context.Context, profile model.AWSProfile, region model.Reg
external.OAICreatorSet,
external.NewS3Client,
external.S3BucketCreatorSet,
external.S3BucketObjectUploaderSet,
external.S3ObjectUploaderSet,
external.S3BucketPublicAccessBlockerSet,
external.S3BucketPolicySetterSet,
interactor.CloudFrontCreatorSet,
Expand Down
53 changes: 35 additions & 18 deletions app/di/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 39 additions & 31 deletions app/domain/service/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ type S3BucketDeleter interface {
DeleteS3Bucket(ctx context.Context, input *S3BucketDeleterInput) (*S3BucketDeleterOutput, error)
}

// S3BucketObjectsDeleterInput is the input of the DeleteBucketObjects method.
type S3BucketObjectsDeleterInput struct {
// S3ObjectsDeleterInput is the input of the DeleteBucketObjects method.
type S3ObjectsDeleterInput struct {
// Bucket is the name of the bucket to delete.
Bucket model.Bucket
// Region is the region of the bucket that you want to delete.
Expand All @@ -79,52 +79,60 @@ type S3BucketObjectsDeleterInput struct {
S3ObjectSets model.S3ObjectIdentifierSets
}

// S3BucketObjectsDeleterOutput is the output of the DeleteBucketObjects method.
type S3BucketObjectsDeleterOutput struct{}
// S3ObjectsDeleterOutput is the output of the DeleteBucketObjects method.
type S3ObjectsDeleterOutput struct{}

// S3BucketObjectsDeleter is the interface that wraps the basic DeleteBucketObjects method.
type S3BucketObjectsDeleter interface {
DeleteS3BucketObjects(ctx context.Context, input *S3BucketObjectsDeleterInput) (*S3BucketObjectsDeleterOutput, error)
// S3ObjectsDeleter is the interface that wraps the basic DeleteBucketObjects method.
type S3ObjectsDeleter interface {
DeleteS3Objects(ctx context.Context, input *S3ObjectsDeleterInput) (*S3ObjectsDeleterOutput, error)
}

// S3BucketObjectsListerInput is the input of the ListBucketObjects method.
type S3BucketObjectsListerInput struct {
// S3ObjectsListerInput is the input of the ListBucketObjects method.
type S3ObjectsListerInput struct {
// Bucket is the name of the bucket to list.
Bucket model.Bucket
}

// S3BucketObjectsListerOutput is the output of the ListBucketObjects method.
type S3BucketObjectsListerOutput struct {
// S3ObjectsListerOutput is the output of the ListBucketObjects method.
type S3ObjectsListerOutput struct {
// Objects is the list of the objects.
Objects model.S3ObjectIdentifierSets
}

// S3BucketObjectsLister is the interface that wraps the basic ListBucketObjects method.
type S3BucketObjectsLister interface {
ListS3BucketObjects(ctx context.Context, input *S3BucketObjectsListerInput) (*S3BucketObjectsListerOutput, error)
// S3ObjectsLister is the interface that wraps the basic ListBucketObjects method.
type S3ObjectsLister interface {
ListS3Objects(ctx context.Context, input *S3ObjectsListerInput) (*S3ObjectsListerOutput, error)
}

// S3BucketObjectDownloaderInput is the input of the GetBucketObject method.
type S3BucketObjectDownloaderInput struct {
// S3ObjectDownloaderInput is the input of the GetBucketObject method.
type S3ObjectDownloaderInput struct {
// Bucket is the name of the bucket to get.
Bucket model.Bucket
// S3Key is the key of the object to get.
S3Key model.S3Key
// Key is the key of the object to get.
Key model.S3Key
}

// S3BucketObjectDownloaderOutput is the output of the GetBucketObject method.
type S3BucketObjectDownloaderOutput struct {
// S3Object is the object.
// S3ObjectDownloaderOutput is the output of the GetBucketObject method.
type S3ObjectDownloaderOutput struct {
// Bucket is the name of the bucket that you want to download.
Bucket model.Bucket
// Key is the S3 key.
Key model.S3Key
// ContentType is the content type of the downloaded file.
ContentType string
// ContentLength is the content length of the downloaded file.
ContentLength int64
// S3Object is the downloaded object.
S3Object *model.S3Object
}

// S3BucketObjectDownloader is the interface that wraps the basic GetBucketObject method.
type S3BucketObjectDownloader interface {
DownloadS3BucketObject(ctx context.Context, input *S3BucketObjectDownloaderInput) (*S3BucketObjectDownloaderOutput, error)
// S3ObjectDownloader is the interface that wraps the basic GetBucketObject method.
type S3ObjectDownloader interface {
DownloadS3Object(ctx context.Context, input *S3ObjectDownloaderInput) (*S3ObjectDownloaderOutput, error)
}

// S3BucketObjectUploaderInput is the input of the PutBucketObject method.
type S3BucketObjectUploaderInput struct {
// S3ObjectUploaderInput is the input of the PutBucketObject method.
type S3ObjectUploaderInput struct {
// Bucket is the name of the bucket to put.
Bucket model.Bucket
// Region is the region of the bucket that you want to put.
Expand All @@ -135,15 +143,15 @@ type S3BucketObjectUploaderInput struct {
S3Object *model.S3Object
}

// S3BucketObjectUploaderOutput is the output of the PutBucketObject method.
type S3BucketObjectUploaderOutput struct {
// S3ObjectUploaderOutput is the output of the PutBucketObject method.
type S3ObjectUploaderOutput struct {
// ContentType is the content type of the object.
ContentType string
// ContentLength is the size of the object.
ContentLength int64
}

// S3BucketObjectUploader is the interface that wraps the basic PutBucketObject method.
type S3BucketObjectUploader interface {
UploadS3BucketObject(ctx context.Context, input *S3BucketObjectUploaderInput) (*S3BucketObjectUploaderOutput, error)
// S3ObjectUploader is the interface that wraps the basic PutBucketObject method.
type S3ObjectUploader interface {
UploadS3Object(ctx context.Context, input *S3ObjectUploaderInput) (*S3ObjectUploaderOutput, error)
}
Loading

0 comments on commit 1208623

Please sign in to comment.