aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/minio/minio-go/v7/api-restore.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/minio/minio-go/v7/api-restore.go')
-rw-r--r--vendor/github.com/minio/minio-go/v7/api-restore.go182
1 files changed, 0 insertions, 182 deletions
diff --git a/vendor/github.com/minio/minio-go/v7/api-restore.go b/vendor/github.com/minio/minio-go/v7/api-restore.go
deleted file mode 100644
index 9ec8f4f..0000000
--- a/vendor/github.com/minio/minio-go/v7/api-restore.go
+++ /dev/null
@@ -1,182 +0,0 @@
1/*
2 * MinIO Go Library for Amazon S3 Compatible Cloud Storage
3 * (C) 2018-2021 MinIO, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package minio
19
20import (
21 "bytes"
22 "context"
23 "encoding/xml"
24 "net/http"
25 "net/url"
26
27 "github.com/minio/minio-go/v7/pkg/s3utils"
28 "github.com/minio/minio-go/v7/pkg/tags"
29)
30
31// RestoreType represents the restore request type
32type RestoreType string
33
34const (
35 // RestoreSelect represents the restore SELECT operation
36 RestoreSelect = RestoreType("SELECT")
37)
38
39// TierType represents a retrieval tier
40type TierType string
41
42const (
43 // TierStandard is the standard retrieval tier
44 TierStandard = TierType("Standard")
45 // TierBulk is the bulk retrieval tier
46 TierBulk = TierType("Bulk")
47 // TierExpedited is the expedited retrieval tier
48 TierExpedited = TierType("Expedited")
49)
50
51// GlacierJobParameters represents the retrieval tier parameter
52type GlacierJobParameters struct {
53 Tier TierType
54}
55
56// Encryption contains the type of server-side encryption used during object retrieval
57type Encryption struct {
58 EncryptionType string
59 KMSContext string
60 KMSKeyID string `xml:"KMSKeyId"`
61}
62
63// MetadataEntry represents a metadata information of the restored object.
64type MetadataEntry struct {
65 Name string
66 Value string
67}
68
69// S3 holds properties of the copy of the archived object
70type S3 struct {
71 AccessControlList *AccessControlList `xml:"AccessControlList,omitempty"`
72 BucketName string
73 Prefix string
74 CannedACL *string `xml:"CannedACL,omitempty"`
75 Encryption *Encryption `xml:"Encryption,omitempty"`
76 StorageClass *string `xml:"StorageClass,omitempty"`
77 Tagging *tags.Tags `xml:"Tagging,omitempty"`
78 UserMetadata *MetadataEntry `xml:"UserMetadata,omitempty"`
79}
80
81// SelectParameters holds the select request parameters
82type SelectParameters struct {
83 XMLName xml.Name `xml:"SelectParameters"`
84 ExpressionType QueryExpressionType
85 Expression string
86 InputSerialization SelectObjectInputSerialization
87 OutputSerialization SelectObjectOutputSerialization
88}
89
90// OutputLocation holds properties of the copy of the archived object
91type OutputLocation struct {
92 XMLName xml.Name `xml:"OutputLocation"`
93 S3 S3 `xml:"S3"`
94}
95
96// RestoreRequest holds properties of the restore object request
97type RestoreRequest struct {
98 XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ RestoreRequest"`
99 Type *RestoreType `xml:"Type,omitempty"`
100 Tier *TierType `xml:"Tier,omitempty"`
101 Days *int `xml:"Days,omitempty"`
102 GlacierJobParameters *GlacierJobParameters `xml:"GlacierJobParameters,omitempty"`
103 Description *string `xml:"Description,omitempty"`
104 SelectParameters *SelectParameters `xml:"SelectParameters,omitempty"`
105 OutputLocation *OutputLocation `xml:"OutputLocation,omitempty"`
106}
107
108// SetDays sets the days parameter of the restore request
109func (r *RestoreRequest) SetDays(v int) {
110 r.Days = &v
111}
112
113// SetGlacierJobParameters sets the GlacierJobParameters of the restore request
114func (r *RestoreRequest) SetGlacierJobParameters(v GlacierJobParameters) {
115 r.GlacierJobParameters = &v
116}
117
118// SetType sets the type of the restore request
119func (r *RestoreRequest) SetType(v RestoreType) {
120 r.Type = &v
121}
122
123// SetTier sets the retrieval tier of the restore request
124func (r *RestoreRequest) SetTier(v TierType) {
125 r.Tier = &v
126}
127
128// SetDescription sets the description of the restore request
129func (r *RestoreRequest) SetDescription(v string) {
130 r.Description = &v
131}
132
133// SetSelectParameters sets SelectParameters of the restore select request
134func (r *RestoreRequest) SetSelectParameters(v SelectParameters) {
135 r.SelectParameters = &v
136}
137
138// SetOutputLocation sets the properties of the copy of the archived object
139func (r *RestoreRequest) SetOutputLocation(v OutputLocation) {
140 r.OutputLocation = &v
141}
142
143// RestoreObject is a implementation of https://docs.aws.amazon.com/AmazonS3/latest/API/API_RestoreObject.html AWS S3 API
144func (c *Client) RestoreObject(ctx context.Context, bucketName, objectName, versionID string, req RestoreRequest) error {
145 // Input validation.
146 if err := s3utils.CheckValidBucketName(bucketName); err != nil {
147 return err
148 }
149 if err := s3utils.CheckValidObjectName(objectName); err != nil {
150 return err
151 }
152
153 restoreRequestBytes, err := xml.Marshal(req)
154 if err != nil {
155 return err
156 }
157
158 urlValues := make(url.Values)
159 urlValues.Set("restore", "")
160 if versionID != "" {
161 urlValues.Set("versionId", versionID)
162 }
163
164 // Execute POST on bucket/object.
165 resp, err := c.executeMethod(ctx, http.MethodPost, requestMetadata{
166 bucketName: bucketName,
167 objectName: objectName,
168 queryValues: urlValues,
169 contentMD5Base64: sumMD5Base64(restoreRequestBytes),
170 contentSHA256Hex: sum256Hex(restoreRequestBytes),
171 contentBody: bytes.NewReader(restoreRequestBytes),
172 contentLength: int64(len(restoreRequestBytes)),
173 })
174 defer closeResponse(resp)
175 if err != nil {
176 return err
177 }
178 if resp.StatusCode != http.StatusAccepted && resp.StatusCode != http.StatusOK {
179 return httpRespToErrorResponse(resp, bucketName, "")
180 }
181 return nil
182}