2015-01-21 08:16:06 +01:00
|
|
|
/*
|
2015-10-16 20:26:01 +02:00
|
|
|
* Minio Cloud Storage, (C) 2015 Minio, Inc.
|
2015-01-21 08:16:06 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2015-09-19 09:52:01 +02:00
|
|
|
package main
|
2015-01-21 01:08:14 +01:00
|
|
|
|
2015-05-14 23:36:41 +02:00
|
|
|
import "encoding/xml"
|
2015-01-21 01:08:14 +01:00
|
|
|
|
2015-02-24 01:46:48 +01:00
|
|
|
// Limit number of objects in a given response
|
2015-01-23 21:14:39 +01:00
|
|
|
const (
|
2015-03-03 03:03:01 +01:00
|
|
|
maxObjectList = 1000
|
2015-01-23 21:14:39 +01:00
|
|
|
)
|
|
|
|
|
2015-10-08 20:12:02 +02:00
|
|
|
// AccessControlPolicyResponse - format for get bucket acl response
|
|
|
|
type AccessControlPolicyResponse struct {
|
|
|
|
AccessControlList struct {
|
|
|
|
Grant []Grant
|
|
|
|
}
|
|
|
|
Owner Owner
|
|
|
|
}
|
|
|
|
|
|
|
|
// Grant container for grantee and permission
|
|
|
|
type Grant struct {
|
|
|
|
Grantee struct {
|
|
|
|
ID string
|
|
|
|
DisplayName string
|
|
|
|
EmailAddress string
|
|
|
|
Type string
|
|
|
|
URI string
|
|
|
|
}
|
|
|
|
Permission string
|
|
|
|
}
|
|
|
|
|
2015-04-30 00:28:04 +02:00
|
|
|
// ListObjectsResponse - format for list objects response
|
|
|
|
type ListObjectsResponse struct {
|
2015-07-02 22:14:21 +02:00
|
|
|
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListBucketResult" json:"-"`
|
2015-05-05 23:27:18 +02:00
|
|
|
|
|
|
|
CommonPrefixes []*CommonPrefix
|
|
|
|
Contents []*Object
|
|
|
|
|
|
|
|
Delimiter string
|
|
|
|
|
|
|
|
// Encoding type used to encode object keys in the response.
|
|
|
|
EncodingType string
|
|
|
|
|
|
|
|
// A flag that indicates whether or not ListObjects returned all of the results
|
|
|
|
// that satisfied the search criteria.
|
|
|
|
IsTruncated bool
|
|
|
|
Marker string
|
|
|
|
MaxKeys int
|
|
|
|
Name string
|
|
|
|
|
|
|
|
// When response is truncated (the IsTruncated element value in the response
|
|
|
|
// is true), you can use the key name in this field as marker in the subsequent
|
2015-07-25 03:09:53 +02:00
|
|
|
// request to get next set of objects. Server lists objects in alphabetical
|
2015-05-05 23:27:18 +02:00
|
|
|
// order Note: This element is returned only if you have delimiter request parameter
|
|
|
|
// specified. If response does not include the NextMaker and it is truncated,
|
|
|
|
// you can use the value of the last Key in the response as the marker in the
|
|
|
|
// subsequent request to get the next set of object keys.
|
|
|
|
NextMarker string
|
|
|
|
Prefix string
|
2015-01-21 09:50:23 +01:00
|
|
|
}
|
|
|
|
|
2015-07-10 04:01:15 +02:00
|
|
|
// Part container for part metadata
|
|
|
|
type Part struct {
|
|
|
|
PartNumber int
|
|
|
|
ETag string
|
|
|
|
LastModified string
|
|
|
|
Size int64
|
|
|
|
}
|
|
|
|
|
2015-05-09 20:41:26 +02:00
|
|
|
// ListPartsResponse - format for list parts response
|
|
|
|
type ListPartsResponse struct {
|
2015-07-02 22:14:21 +02:00
|
|
|
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListPartsResult" json:"-"`
|
2015-05-09 20:41:26 +02:00
|
|
|
|
|
|
|
Bucket string
|
|
|
|
Key string
|
|
|
|
UploadID string `xml:"UploadId"`
|
|
|
|
|
|
|
|
Initiator Initiator
|
|
|
|
Owner Owner
|
|
|
|
|
|
|
|
// The class of storage used to store the object.
|
|
|
|
StorageClass string
|
|
|
|
|
|
|
|
PartNumberMarker int
|
|
|
|
NextPartNumberMarker int
|
|
|
|
MaxParts int
|
|
|
|
IsTruncated bool
|
|
|
|
|
|
|
|
// List of parts
|
|
|
|
Part []*Part
|
|
|
|
}
|
|
|
|
|
2015-05-14 23:36:41 +02:00
|
|
|
// ListMultipartUploadsResponse - format for list multipart uploads response
|
|
|
|
type ListMultipartUploadsResponse struct {
|
2015-07-02 22:14:21 +02:00
|
|
|
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListMultipartUploadsResult" json:"-"`
|
2015-05-14 23:36:41 +02:00
|
|
|
|
|
|
|
Bucket string
|
|
|
|
KeyMarker string
|
|
|
|
UploadIDMarker string `xml:"UploadIdMarker"`
|
|
|
|
NextKeyMarker string
|
|
|
|
NextUploadIDMarker string `xml:"NextUploadIdMarker"`
|
|
|
|
EncodingType string
|
|
|
|
MaxUploads int
|
|
|
|
IsTruncated bool
|
|
|
|
Upload []*Upload
|
|
|
|
Prefix string
|
|
|
|
Delimiter string
|
|
|
|
CommonPrefixes []*CommonPrefix
|
|
|
|
}
|
|
|
|
|
2015-04-30 00:28:04 +02:00
|
|
|
// ListBucketsResponse - format for list buckets response
|
|
|
|
type ListBucketsResponse struct {
|
2015-07-02 22:14:21 +02:00
|
|
|
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListAllMyBucketsResult" json:"-"`
|
2015-05-05 23:27:18 +02:00
|
|
|
// Container for one or more buckets.
|
2015-01-23 10:55:01 +01:00
|
|
|
Buckets struct {
|
|
|
|
Bucket []*Bucket
|
2015-03-04 23:24:56 +01:00
|
|
|
} // Buckets are nested
|
2015-05-05 23:27:18 +02:00
|
|
|
Owner Owner
|
2015-01-21 09:50:23 +01:00
|
|
|
}
|
|
|
|
|
2015-05-14 23:36:41 +02:00
|
|
|
// Upload container for in progress multipart upload
|
|
|
|
type Upload struct {
|
|
|
|
Key string
|
|
|
|
UploadID string `xml:"UploadId"`
|
|
|
|
Initiator Initiator
|
|
|
|
Owner Owner
|
|
|
|
StorageClass string
|
|
|
|
Initiated string
|
|
|
|
}
|
|
|
|
|
2015-05-05 23:27:18 +02:00
|
|
|
// CommonPrefix container for prefix response in ListObjectsResponse
|
|
|
|
type CommonPrefix struct {
|
2015-02-28 23:44:26 +01:00
|
|
|
Prefix string
|
|
|
|
}
|
|
|
|
|
2015-05-05 23:27:18 +02:00
|
|
|
// Bucket container for bucket metadata
|
2015-01-21 09:50:23 +01:00
|
|
|
type Bucket struct {
|
|
|
|
Name string
|
|
|
|
CreationDate string
|
2015-01-21 01:08:14 +01:00
|
|
|
}
|
|
|
|
|
2015-05-05 23:27:18 +02:00
|
|
|
// Object container for object metadata
|
|
|
|
type Object struct {
|
|
|
|
ETag string
|
2015-01-21 01:08:14 +01:00
|
|
|
Key string
|
|
|
|
LastModified string
|
2015-01-26 02:41:59 +01:00
|
|
|
Size int64
|
2015-05-05 23:27:18 +02:00
|
|
|
|
|
|
|
Owner Owner
|
|
|
|
|
|
|
|
// The class of storage used to store the object.
|
2015-01-21 01:08:14 +01:00
|
|
|
StorageClass string
|
|
|
|
}
|
|
|
|
|
2015-05-09 20:41:26 +02:00
|
|
|
// Initiator inherit from Owner struct, fields are same
|
|
|
|
type Initiator Owner
|
|
|
|
|
2015-03-06 06:07:19 +01:00
|
|
|
// Owner - bucket owner/principal
|
2015-01-21 01:08:14 +01:00
|
|
|
type Owner struct {
|
|
|
|
ID string
|
|
|
|
DisplayName string
|
|
|
|
}
|
2015-01-25 01:35:33 +01:00
|
|
|
|
2015-07-10 04:01:15 +02:00
|
|
|
// InitiateMultipartUploadResponse container for InitiateMultiPartUpload response, provides uploadID to start MultiPart upload
|
|
|
|
type InitiateMultipartUploadResponse struct {
|
2015-07-02 22:14:21 +02:00
|
|
|
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ InitiateMultipartUploadResult" json:"-"`
|
2015-05-08 04:55:30 +02:00
|
|
|
|
|
|
|
Bucket string
|
|
|
|
Key string
|
|
|
|
UploadID string `xml:"UploadId"`
|
|
|
|
}
|
|
|
|
|
2015-07-10 04:01:15 +02:00
|
|
|
// CompleteMultipartUploadResponse container for completed multipart upload response
|
|
|
|
type CompleteMultipartUploadResponse struct {
|
2015-07-02 22:14:21 +02:00
|
|
|
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CompleteMultipartUploadResult" json:"-"`
|
2015-05-08 07:43:19 +02:00
|
|
|
|
|
|
|
Location string
|
|
|
|
Bucket string
|
|
|
|
Key string
|
|
|
|
ETag string
|
|
|
|
}
|
|
|
|
|
2015-02-24 01:46:48 +01:00
|
|
|
// List of not implemented bucket queries
|
2015-04-30 00:28:04 +02:00
|
|
|
var notimplementedBucketResourceNames = map[string]bool{
|
2015-04-22 23:44:59 +02:00
|
|
|
"policy": true,
|
2015-02-16 02:03:27 +01:00
|
|
|
"cors": true,
|
2015-01-25 01:35:33 +01:00
|
|
|
"lifecycle": true,
|
|
|
|
"location": true,
|
|
|
|
"logging": true,
|
|
|
|
"notification": true,
|
2015-10-08 20:12:02 +02:00
|
|
|
"replication": true,
|
2015-02-16 02:03:27 +01:00
|
|
|
"tagging": true,
|
2015-01-25 01:35:33 +01:00
|
|
|
"versions": true,
|
|
|
|
"requestPayment": true,
|
|
|
|
"versioning": true,
|
|
|
|
"website": true,
|
|
|
|
}
|
|
|
|
|
2015-02-24 01:46:48 +01:00
|
|
|
// List of not implemented object queries
|
2015-04-30 00:28:04 +02:00
|
|
|
var notimplementedObjectResourceNames = map[string]bool{
|
2015-05-08 04:55:30 +02:00
|
|
|
"torrent": true,
|
2015-10-08 05:36:36 +02:00
|
|
|
"acl": true,
|
|
|
|
"policy": true,
|
2015-01-25 01:35:33 +01:00
|
|
|
}
|