Skip to content

Commit

Permalink
remove unused operations
Browse files Browse the repository at this point in the history
  • Loading branch information
hgiasac committed Jan 20, 2025
1 parent 09af503 commit dfc93a6
Show file tree
Hide file tree
Showing 19 changed files with 158 additions and 1,597 deletions.
43 changes: 0 additions & 43 deletions connector/functions/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,46 +77,3 @@ func ProcedureUpdateStorageBucket(ctx context.Context, state *types.State, args

return true, nil
}

// FunctionStorageBucketPolicy gets access permissions on a bucket or a prefix.
func FunctionStorageBucketPolicy(ctx context.Context, state *types.State, args *common.StorageBucketArguments) (string, error) {
return state.Storage.GetBucketPolicy(ctx, args)
}

// FunctionStorageBucketNotification gets notification configuration on a bucket.
func FunctionStorageBucketNotification(ctx context.Context, state *types.State, args *common.StorageBucketArguments) (*common.NotificationConfig, error) {
return state.Storage.GetBucketNotification(ctx, args)
}

// ProcedureSetStorageBucketNotification sets a new notification configuration on a bucket.
func ProcedureSetStorageBucketNotification(ctx context.Context, state *types.State, args *common.SetBucketNotificationArguments) (bool, error) {
if err := state.Storage.SetBucketNotification(ctx, args); err != nil {
return false, err
}

return true, nil
}

// ProcedureSetStorageBucketReplication sets replication configuration on a bucket. Role can be obtained by first defining the replication target on MinIO
// to associate the source and destination buckets for replication with the replication endpoint.
func ProcedureSetStorageBucketReplication(ctx context.Context, state *types.State, args *common.SetStorageBucketReplicationArguments) (bool, error) {
if err := state.Storage.SetBucketReplication(ctx, args); err != nil {
return false, err
}

return true, nil
}

// FunctionGetBucketReplication gets current replication config on a bucket.
func FunctionStorageBucketReplication(ctx context.Context, state *types.State, args *common.StorageBucketArguments) (*common.StorageReplicationConfig, error) {
return state.Storage.GetBucketReplication(ctx, args)
}

// RemoveBucketReplication removes replication configuration on a bucket.
func ProcedureRemoveStorageBucketReplication(ctx context.Context, state *types.State, args *common.StorageBucketArguments) (bool, error) {
if err := state.Storage.RemoveBucketReplication(ctx, args); err != nil {
return false, err
}

return true, nil
}
146 changes: 146 additions & 0 deletions connector/functions/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,149 @@ func FunctionStoragePresignedUploadUrl(ctx context.Context, state *types.State,
func FunctionStorageIncompleteUploads(ctx context.Context, state *types.State, args *common.ListIncompleteUploadsArguments) ([]common.StorageObjectMultipartInfo, error) {
return state.Storage.ListIncompleteUploads(ctx, args.StorageBucketArguments, args.ListIncompleteUploadsOptions)
}

// PutStorageObjectArguments represents input arguments of the PutObject method.
type PutStorageObjectArguments struct {
common.StorageBucketArguments

Object string `json:"object"`
Options common.PutStorageObjectOptions `json:"options,omitempty"`
Where schema.Expression `json:"where" ndc:"predicate=StorageObjectSimple"`
}

// PutStorageObjectArguments represents input arguments of the PutObject method.
type PutStorageObjectBase64Arguments struct {
PutStorageObjectArguments

Data scalar.Bytes `json:"data"`
}

// ProcedureUploadStorageObject uploads object that are less than 128MiB in a single PUT operation. For objects that are greater than 128MiB in size,
// PutObject seamlessly uploads the object as parts of 128MiB or more depending on the actual file size. The max upload size for an object is 5TB.
func ProcedureUploadStorageObject(ctx context.Context, state *types.State, args *PutStorageObjectBase64Arguments) (common.StorageUploadInfo, error) {
return uploadStorageObject(ctx, state, &args.PutStorageObjectArguments, args.Data.Bytes())
}

func uploadStorageObject(ctx context.Context, state *types.State, args *PutStorageObjectArguments, data []byte) (common.StorageUploadInfo, error) {
request, err := internal.EvalObjectPredicate(args.StorageBucketArguments, args.Object, args.Where, types.QueryVariablesFromContext(ctx))
if err != nil {
return common.StorageUploadInfo{}, err
}

if !request.IsValid {
return common.StorageUploadInfo{}, schema.ForbiddenError("permission dennied", nil)
}

result, err := state.Storage.PutObject(ctx, request.StorageBucketArguments, request.Prefix, &args.Options, data)
if err != nil {
return common.StorageUploadInfo{}, err
}

return *result, nil
}

// PutStorageObjectTextArguments represents input arguments of the PutStorageObjectText method.
type PutStorageObjectTextArguments struct {
PutStorageObjectArguments

Data string `json:"data"`
}

// ProcedureUploadStorageObjectText uploads object in plain text to the storage server. The file content is not encoded to base64 so the input size is smaller than 30%.
func ProcedureUploadStorageObjectText(ctx context.Context, state *types.State, args *PutStorageObjectTextArguments) (common.StorageUploadInfo, error) {
return uploadStorageObject(ctx, state, &args.PutStorageObjectArguments, []byte(args.Data))
}

// ProcedureCopyStorageObject creates or replaces an object through server-side copying of an existing object.
// It supports conditional copying, copying a part of an object and server-side encryption of destination and decryption of source.
// To copy multiple source objects into a single destination object see the ComposeObject API.
func ProcedureCopyStorageObject(ctx context.Context, state *types.State, args *common.CopyStorageObjectArguments) (common.StorageUploadInfo, error) {
result, err := state.Storage.CopyObject(ctx, args)
if err != nil {
return common.StorageUploadInfo{}, err
}

return *result, nil
}

// ProcedureComposeStorageObject creates an object by concatenating a list of source objects using server-side copying.
func ProcedureComposeStorageObject(ctx context.Context, state *types.State, args *common.ComposeStorageObjectArguments) (common.StorageUploadInfo, error) {
result, err := state.Storage.ComposeObject(ctx, args)
if err != nil {
return common.StorageUploadInfo{}, err
}

return *result, nil
}

// ProcedureUpdateStorageObject updates the object's configuration.
func ProcedureUpdateStorageObject(ctx context.Context, state *types.State, args *common.UpdateStorageObjectArguments) (bool, error) {
request, err := internal.EvalObjectPredicate(args.StorageBucketArguments, args.Object, args.Where, types.QueryVariablesFromContext(ctx))
if err != nil {
return false, err
}

if !request.IsValid {
return false, errPermissionDenied
}

if err := state.Storage.UpdateObject(ctx, request.StorageBucketArguments, request.Prefix, args.UpdateStorageObjectOptions); err != nil {
return false, err
}

return true, nil
}

// ProcedureRemoveStorageObject removes an object with some specified options.
func ProcedureRemoveStorageObject(ctx context.Context, state *types.State, args *common.RemoveStorageObjectArguments) (bool, error) {
request, err := internal.EvalObjectPredicate(args.StorageBucketArguments, args.Object, args.Where, types.QueryVariablesFromContext(ctx))
if err != nil {
return false, err
}

if !request.IsValid {
return false, errPermissionDenied
}

if err := state.Storage.RemoveObject(ctx, request.StorageBucketArguments, request.Prefix, args.RemoveStorageObjectOptions); err != nil {
return false, err
}

return true, nil
}

// ProcedureRemoveStorageObjects remove a list of objects obtained from an input channel. The call sends a delete request to the server up to 1000 objects at a time.
// The errors observed are sent over the error channel.
func ProcedureRemoveStorageObjects(ctx context.Context, state *types.State, args *common.RemoveStorageObjectsArguments) ([]common.RemoveStorageObjectError, error) {
request, err := internal.EvalObjectPredicate(args.StorageBucketArguments, "", args.Where, types.QueryVariablesFromContext(ctx))
if err != nil {
return nil, err
}

if !request.IsValid {
return nil, nil
}

predicate := request.CheckPostObjectNamePredicate
if !request.HasPostPredicate() {
predicate = nil
}

return state.Storage.RemoveObjects(ctx, request.StorageBucketArguments, &common.RemoveStorageObjectsOptions{
ListStorageObjectsOptions: common.ListStorageObjectsOptions{
Prefix: request.Prefix,
Recursive: args.Recursive,
StartAfter: args.StartAfter,
},
GovernanceBypass: args.GovernanceBypass,
}, predicate)
}

// ProcedureRemoveIncompleteStorageUpload removes a partially uploaded object.
func ProcedureRemoveIncompleteStorageUpload(ctx context.Context, state *types.State, args *common.RemoveIncompleteUploadArguments) (bool, error) {
if err := state.Storage.RemoveIncompleteUpload(ctx, args); err != nil {
return false, err
}

return true, nil
}
157 changes: 0 additions & 157 deletions connector/functions/object_cud.go

This file was deleted.

Loading

0 comments on commit dfc93a6

Please sign in to comment.