minio/cmd/storage-rpc-server-datatypes.go

173 lines
3.8 KiB
Go
Raw Normal View History

/*
* Minio Cloud Storage, (C) 2016 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cmd
import "time"
// TokenSetter is to be implemented by types that need a way to update member that represents a token.
// e.g, See GenericArgs.
type TokenSetter interface {
SetToken(token string)
SetTimestamp(tstamp time.Time)
}
// GenericReply represents any generic RPC reply.
type GenericReply struct {
}
// GenericArgs represents any generic RPC arguments.
type GenericArgs struct {
Token string // Used to authenticate every RPC call.
Timestamp time.Time // Used to verify if the RPC call was issued between the same Login() and disconnect event pair.
}
// SetToken - sets the token to the supplied value.
func (ga *GenericArgs) SetToken(token string) {
ga.Token = token
}
// SetTimestamp - sets the timestamp to the supplied value.
func (ga *GenericArgs) SetTimestamp(tstamp time.Time) {
ga.Timestamp = tstamp
}
2016-08-11 06:09:31 +02:00
// RPCLoginArgs - login username and password for RPC.
type RPCLoginArgs struct {
Username string
Password string
}
// RPCLoginReply - login reply provides generated token to be used
// with subsequent requests.
type RPCLoginReply struct {
Token string
ServerVersion string
Timestamp time.Time
2016-08-11 06:09:31 +02:00
}
// GenericVolArgs - generic volume args.
type GenericVolArgs struct {
// Authentication token generated by Login.
GenericArgs
2016-08-11 06:09:31 +02:00
// Name of the volume.
Vol string
}
// ListVolsReply represents list of vols RPC reply.
type ListVolsReply struct {
// List of volumes stat information.
Vols []VolInfo
}
// ReadAllArgs represents read all RPC arguments.
type ReadAllArgs struct {
2016-08-11 06:09:31 +02:00
// Authentication token generated by Login.
GenericArgs
// Name of the volume.
Vol string
// Name of the path.
Path string
}
// ReadFileArgs represents read file RPC arguments.
type ReadFileArgs struct {
2016-08-11 06:09:31 +02:00
// Authentication token generated by Login.
GenericArgs
// Name of the volume.
Vol string
// Name of the path.
Path string
// Starting offset to start reading into Buffer.
Offset int64
// Data size read from the path at offset.
Size int
}
// AppendFileArgs represents append file RPC arguments.
type AppendFileArgs struct {
2016-08-11 06:09:31 +02:00
// Authentication token generated by Login.
GenericArgs
2016-08-11 06:09:31 +02:00
// Name of the volume.
Vol string
// Name of the path.
Path string
// Data buffer to be saved at path.
Buffer []byte
}
// StatFileArgs represents stat file RPC arguments.
type StatFileArgs struct {
2016-08-11 06:09:31 +02:00
// Authentication token generated by Login.
GenericArgs
2016-08-11 06:09:31 +02:00
// Name of the volume.
Vol string
// Name of the path.
Path string
}
// DeleteFileArgs represents delete file RPC arguments.
type DeleteFileArgs struct {
2016-08-11 06:09:31 +02:00
// Authentication token generated by Login.
GenericArgs
2016-08-11 06:09:31 +02:00
// Name of the volume.
Vol string
// Name of the path.
Path string
}
// ListDirArgs represents list contents RPC arguments.
type ListDirArgs struct {
2016-08-11 06:09:31 +02:00
// Authentication token generated by Login.
GenericArgs
2016-08-11 06:09:31 +02:00
// Name of the volume.
Vol string
// Name of the path.
Path string
}
// RenameFileArgs represents rename file RPC arguments.
type RenameFileArgs struct {
2016-08-11 06:09:31 +02:00
// Authentication token generated by Login.
GenericArgs
2016-08-11 06:09:31 +02:00
// Name of source volume.
SrcVol string
// Source path to be renamed.
SrcPath string
// Name of destination volume.
DstVol string
// Destination path of renamed file.
DstPath string
}