Documentation ¶
Overview ¶
Package storage implements storage operation
Index ¶
- Constants
- func Copy(context *endly.Context, transfers ...*copy.Rule) (interface{}, error)
- func GetResourceWithOptions(context *endly.Context, resource *location.Resource, options ...storage.Option) (*location.Resource, []storage.Option, error)
- func IsCompressable(protScheme string) bool
- func New() endly.Service
- func StorageOptions(ctx *endly.Context, resource *location.Resource, options ...storage.Option) ([]storage.Option, error)
- func StorageService(ctx *endly.Context, resources ...*location.Resource) (afs.Service, error)
- func UseMemoryService(context *endly.Context) afs.Service
- type CopyRequest
- type CopyResponse
- type CreateRequest
- type CreateResponse
- type DownloadRequest
- type DownloadResponse
- type ExistsRequest
- type ExistsResponse
- type GenerateRequest
- type GenerateResponse
- type ListRequest
- type ListResponse
- type RemoveRequest
- type RemoveResponse
- type UploadRequest
- type UploadResponse
Examples ¶
Constants ¶
const (
//ServiceID represents transfer service id
ServiceID = "storage"
)
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
Copy transfers data for provided transfer definition.
Example ¶
package main import ( "github.com/viant/endly" "github.com/viant/endly/model/location" "github.com/viant/endly/service/system/storage" "log" ) func main() { request := storage.NewCopyRequest(nil, copy.New(location.NewResource("/tmp/folde"), location.NewResource("s3://mybucket/data", "aws-e2e"), false, true, nil)) response := &storage.CopyResponse{} err := endly.Run(nil, request, response) if err != nil { log.Fatal(err) } }
Output:
func GetResourceWithOptions ¶
func GetResourceWithOptions(context *endly.Context, resource *location.Resource, options ...storage.Option) (*location.Resource, []storage.Option, error)
GetResourceWithOptions returns resource with afs storage option
func IsCompressable ¶
IsCompressable returns true if resource can be compress via shell command.
func StorageOptions ¶
func StorageOptions(ctx *endly.Context, resource *location.Resource, options ...storage.Option) ([]storage.Option, error)
StorageOptions returns storage option for supplied resource
func StorageService ¶
StorageService return afs storage service
Types ¶
type CopyRequest ¶
type CopyRequest struct { *copy.Rule `description:"if asset uses relative path it will be joined with this URL" json:",inline"` Assets copy.Assets `` // transfers /* 130-byte string literal not displayed */ Transfers []*copy.Rule `description:"actual transfer assets, if empty it derives from assets or source/desc "` Udf string `description:"custom user defined function to return github.com/viant/afs/option.Modifier type to modify copied content"` }
CopyRequest represents a resources Copy request
func NewCopyRequest ¶
func NewCopyRequest(assets copy.Assets, transfers ...*copy.Rule) *CopyRequest
CopyRequest creates a new Copy request
func NewCopyRequestFromURL ¶
func NewCopyRequestFromURL(URL string) (*CopyRequest, error)
NewCopyRequestFromURL creates a new request from URL (JSON or YAML format are supported)
func (*CopyRequest) Messages ¶
func (r *CopyRequest) Messages() []*msg.Message
Items returns event messages
func (*CopyRequest) Validate ¶
func (r *CopyRequest) Validate() error
Validate checks if request is valid
type CopyResponse ¶
type CopyResponse struct {
URLs []string //transferred URLs
}
CopyResponse represents a resources Copy response
type CreateRequest ¶
type CreateRequest struct { SourceKey string `required:"true" description:"state key with asset content"` Region string `description:"cloud storage region"` Mode int `description:"os.FileMode"` IsDir bool `description:"is directory flag"` Dest *location.Resource `required:"true" description:"destination asset or directory"` //target URL with credentials }
CreateRequest represents a resources Upload request, it takes context state key to Upload to target destination.
func (*CreateRequest) Validate ¶
func (r *CreateRequest) Validate() error
Validate checks if request is valid
type CreateResponse ¶
CreateResponse represents a Upload response
type DownloadRequest ¶
type DownloadRequest struct { Source *location.Resource `required:"true" description:"source asset or directory"` DestKey string `required:"true" description:"state map key destination"` Udf string `description:"name of udf to transform payload before placing into state map"` //name of udf function that will be used to transform payload Expect interface{} `description:"if specified expected file content used for validation"` }
DownloadRequest represents a resources Download request, it downloads source into context.state target key
func (*DownloadRequest) Messages ¶
func (r *DownloadRequest) Messages() []*msg.Message
Items returns event messages
func (*DownloadRequest) Validate ¶
func (r *DownloadRequest) Validate() error
Validate checks if request is valid
type DownloadResponse ¶
type DownloadResponse struct { Info toolbox.FileInfo Payload string //source content, if binary then is will be prefixed base64: followed by based 64 encoded content. Transformed interface{} Assert *validator.AssertResponse }
DownloadResponse represents a Download response
type ExistsRequest ¶
type ExistsRequest struct { Assets []*location.Resource `required:"true" description:"source asset or directory"` Expect map[string]bool `description:"map of asset and exists flag"` }
ExistsRequest represents exists request
func (*ExistsRequest) Validate ¶
func (r *ExistsRequest) Validate() error
Validate checks if request is valid
type ExistsResponse ¶
type ExistsResponse struct { Exists map[string]bool `description:"locations with exists flag, when assets uses only asset location otherwise source URL"` Assert *validator.AssertResponse }
ExistsResponse represents exists response
func (*ExistsResponse) Messages ¶
func (r *ExistsResponse) Messages() []*msg.Message
Items returns event messages
type GenerateRequest ¶
type GenerateRequest struct { Template string LineTemplate string Lines int Size int SizeInMb int Index int IndexVariable string Mode int `description:"os.FileMode"` Dest *location.Resource `required:"true" description:"destination asset or directory"` //target URL with credentials FileCount int InBackground bool }
CreateRequest represents a resources Upload request, it takes context state key to Upload to target destination.
func (*GenerateRequest) Init ¶
func (r *GenerateRequest) Init() error
Init initialises Upload request
func (*GenerateRequest) Messages ¶
func (r *GenerateRequest) Messages() []*msg.Message
Items returns event messages
func (*GenerateRequest) Validate ¶
func (r *GenerateRequest) Validate() error
Validate checks if request is valid
type GenerateResponse ¶
CreateResponse represents a Upload response
func (*GenerateResponse) Messages ¶
func (r *GenerateResponse) Messages() []*msg.Message
Items returns event messages
type ListRequest ¶
type ListRequest struct { Source *location.Resource `required:"true" description:"source asset or directory"` Match *copy.Matcher Content bool Recursive bool Expect interface{} }
DownloadRequest represents a resources Download request, it downloads source into context.state target key
func (*ListRequest) Validate ¶
func (r *ListRequest) Validate() error
Validate checks if request is valid
type ListResponse ¶
type ListResponse struct { URL string Assets []*asset.Resource Assert *validator.AssertResponse }
DownloadResponse represents a Download response
func (*ListResponse) Messages ¶
func (r *ListResponse) Messages() []*msg.Message
Items returns event messages
type RemoveRequest ¶
type RemoveRequest struct {
Assets []*location.Resource `required:"true" description:"resources to Remove"`
}
RemoveRequest represents a resources Remove request
func NewRemoveRequest ¶
func NewRemoveRequest(assets ...*location.Resource) *RemoveRequest
NewRemoveRequest creates a new Remove request
func (*RemoveRequest) Messages ¶
func (r *RemoveRequest) Messages() []*msg.Message
Items returns tag messages
func (*RemoveRequest) Validate ¶
func (r *RemoveRequest) Validate() error
Validate checks if request is valid
type RemoveResponse ¶
type RemoveResponse struct {
Removed []string
}
RemoveResponse represents a resources Remove response, it returns url of all resource that have been removed.
type UploadRequest ¶
type UploadRequest struct { SourceKey string `required:"true" description:"state key with asset content"` Region string `description:"cloud storage region"` Mode int `description:"os.FileMode"` Udf string `description:"name of udf to transform payload before placing into state map"` //name of udf function that will be used to transform payload Dest *location.Resource `required:"true" description:"destination asset or directory"` //target URL with credentials }
UploadRequest represents a resources Upload request, it takes context state key to Upload to target destination.
func (*UploadRequest) Messages ¶
func (r *UploadRequest) Messages() []*msg.Message
Items returns event messages
func (*UploadRequest) Validate ¶
func (r *UploadRequest) Validate() error
Validate checks if request is valid
type UploadResponse ¶
UploadResponse represents a Upload response