aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Azure/azure-storage-blob-go/2018-03-28/azblob/zz_generated_service.go
blob: 76f235e1595b5a5d59fc84fc28c0d5d3320bfb0f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
package azblob

// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

import (
    "bytes"
    "context"
    "encoding/xml"
    "github.com/Azure/azure-pipeline-go/pipeline"
    "io"
    "io/ioutil"
    "net/http"
    "net/url"
    "strconv"
)

// serviceClient is the client for the Service methods of the Azblob service.
type serviceClient struct {
    managementClient
}

// newServiceClient creates an instance of the serviceClient client.
func newServiceClient(url url.URL, p pipeline.Pipeline) serviceClient {
    return serviceClient{newManagementClient(url, p)}
}

// GetProperties gets the properties of a storage account's Blob service, including properties for Storage Analytics
// and CORS (Cross-Origin Resource Sharing) rules.
//
// timeout is the timeout parameter is expressed in seconds. For more information, see <a
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
// Timeouts for Blob Service Operations.</a> requestID is provides a client-generated, opaque value with a 1 KB
// character limit that is recorded in the analytics logs when storage analytics logging is enabled.
func (client serviceClient) GetProperties(ctx context.Context, timeout *int32, requestID *string) (*StorageServiceProperties, error) {
    if err := validate([]validation{
        {targetValue: timeout,
            constraints: []constraint{{target: "timeout", name: null, rule: false,
                chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
        return nil, err
    }
    req, err := client.getPropertiesPreparer(timeout, requestID)
    if err != nil {
        return nil, err
    }
    resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.getPropertiesResponder}, req)
    if err != nil {
        return nil, err
    }
    return resp.(*StorageServiceProperties), err
}

// getPropertiesPreparer prepares the GetProperties request.
func (client serviceClient) getPropertiesPreparer(timeout *int32, requestID *string) (pipeline.Request, error) {
    req, err := pipeline.NewRequest("GET", client.url, nil)
    if err != nil {
        return req, pipeline.NewError(err, "failed to create request")
    }
    params := req.URL.Query()
    if timeout != nil {
        params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
    }
    params.Set("restype", "service")
    params.Set("comp", "properties")
    req.URL.RawQuery = params.Encode()
    req.Header.Set("x-ms-version", ServiceVersion)
    if requestID != nil {
        req.Header.Set("x-ms-client-request-id", *requestID)
    }
    return req, nil
}

// getPropertiesResponder handles the response to the GetProperties request.
func (client serviceClient) getPropertiesResponder(resp pipeline.Response) (pipeline.Response, error) {
    err := validateResponse(resp, http.StatusOK)
    if resp == nil {
        return nil, err
    }
    result := &StorageServiceProperties{rawResponse: resp.Response()}
    if err != nil {
        return result, err
    }
    defer resp.Response().Body.Close()
    b, err := ioutil.ReadAll(resp.Response().Body)
    if err != nil {
        return result, NewResponseError(err, resp.Response(), "failed to read response body")
    }
    if len(b) > 0 {
        b = removeBOM(b)
        err = xml.Unmarshal(b, result)
        if err != nil {
            return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body")
        }
    }
    return result, nil
}

// GetStatistics retrieves statistics related to replication for the Blob service. It is only available on the
// secondary location endpoint when read-access geo-redundant replication is enabled for the storage account.
//
// timeout is the timeout parameter is expressed in seconds. For more information, see <a
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
// Timeouts for Blob Service Operations.</a> requestID is provides a client-generated, opaque value with a 1 KB
// character limit that is recorded in the analytics logs when storage analytics logging is enabled.
func (client serviceClient) GetStatistics(ctx context.Context, timeout *int32, requestID *string) (*StorageServiceStats, error) {
    if err := validate([]validation{
        {targetValue: timeout,
            constraints: []constraint{{target: "timeout", name: null, rule: false,
                chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
        return nil, err
    }
    req, err := client.getStatisticsPreparer(timeout, requestID)
    if err != nil {
        return nil, err
    }
    resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.getStatisticsResponder}, req)
    if err != nil {
        return nil, err
    }
    return resp.(*StorageServiceStats), err
}

// getStatisticsPreparer prepares the GetStatistics request.
func (client serviceClient) getStatisticsPreparer(timeout *int32, requestID *string) (pipeline.Request, error) {
    req, err := pipeline.NewRequest("GET", client.url, nil)
    if err != nil {
        return req, pipeline.NewError(err, "failed to create request")
    }
    params := req.URL.Query()
    if timeout != nil {
        params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
    }
    params.Set("restype", "service")
    params.Set("comp", "stats")
    req.URL.RawQuery = params.Encode()
    req.Header.Set("x-ms-version", ServiceVersion)
    if requestID != nil {
        req.Header.Set("x-ms-client-request-id", *requestID)
    }
    return req, nil
}

// getStatisticsResponder handles the response to the GetStatistics request.
func (client serviceClient) getStatisticsResponder(resp pipeline.Response) (pipeline.Response, error) {
    err := validateResponse(resp, http.StatusOK)
    if resp == nil {
        return nil, err
    }
    result := &StorageServiceStats{rawResponse: resp.Response()}
    if err != nil {
        return result, err
    }
    defer resp.Response().Body.Close()
    b, err := ioutil.ReadAll(resp.Response().Body)
    if err != nil {
        return result, NewResponseError(err, resp.Response(), "failed to read response body")
    }
    if len(b) > 0 {
        b = removeBOM(b)
        err = xml.Unmarshal(b, result)
        if err != nil {
            return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body")
        }
    }
    return result, nil
}

// ListContainersSegment the List Containers Segment operation returns a list of the containers under the specified
// account
//
// prefix is filters the results to return only containers whose name begins with the specified prefix. marker is a
// string value that identifies the portion of the list of containers to be returned with the next listing operation.
// The operation returns the NextMarker value within the response body if the listing operation did not return all
// containers remaining to be listed with the current page. The NextMarker value can be used as the value for the
// marker parameter in a subsequent call to request the next page of list items. The marker value is opaque to the
// client. maxresults is specifies the maximum number of containers to return. If the request does not specify
// maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the
// listing operation crosses a partition boundary, then the service will return a continuation token for retrieving the
// remainder of the results. For this reason, it is possible that the service will return fewer results than specified
// by maxresults, or than the default of 5000. include is include this parameter to specify that the container's
// metadata be returned as part of the response body. timeout is the timeout parameter is expressed in seconds. For
// more information, see <a
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
// Timeouts for Blob Service Operations.</a> requestID is provides a client-generated, opaque value with a 1 KB
// character limit that is recorded in the analytics logs when storage analytics logging is enabled.
func (client serviceClient) ListContainersSegment(ctx context.Context, prefix *string, marker *string, maxresults *int32, include ListContainersIncludeType, timeout *int32, requestID *string) (*ListContainersResponse, error) {
    if err := validate([]validation{
        {targetValue: maxresults,
            constraints: []constraint{{target: "maxresults", name: null, rule: false,
                chain: []constraint{{target: "maxresults", name: inclusiveMinimum, rule: 1, chain: nil}}}}},
        {targetValue: timeout,
            constraints: []constraint{{target: "timeout", name: null, rule: false,
                chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
        return nil, err
    }
    req, err := client.listContainersSegmentPreparer(prefix, marker, maxresults, include, timeout, requestID)
    if err != nil {
        return nil, err
    }
    resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.listContainersSegmentResponder}, req)
    if err != nil {
        return nil, err
    }
    return resp.(*ListContainersResponse), err
}

// listContainersSegmentPreparer prepares the ListContainersSegment request.
func (client serviceClient) listContainersSegmentPreparer(prefix *string, marker *string, maxresults *int32, include ListContainersIncludeType, timeout *int32, requestID *string) (pipeline.Request, error) {
    req, err := pipeline.NewRequest("GET", client.url, nil)
    if err != nil {
        return req, pipeline.NewError(err, "failed to create request")
    }
    params := req.URL.Query()
    if prefix != nil && len(*prefix) > 0 {
        params.Set("prefix", *prefix)
    }
    if marker != nil && len(*marker) > 0 {
        params.Set("marker", *marker)
    }
    if maxresults != nil {
        params.Set("maxresults", strconv.FormatInt(int64(*maxresults), 10))
    }
    if include != ListContainersIncludeNone {
        params.Set("include", string(include))
    }
    if timeout != nil {
        params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
    }
    params.Set("comp", "list")
    req.URL.RawQuery = params.Encode()
    req.Header.Set("x-ms-version", ServiceVersion)
    if requestID != nil {
        req.Header.Set("x-ms-client-request-id", *requestID)
    }
    return req, nil
}

// listContainersSegmentResponder handles the response to the ListContainersSegment request.
func (client serviceClient) listContainersSegmentResponder(resp pipeline.Response) (pipeline.Response, error) {
    err := validateResponse(resp, http.StatusOK)
    if resp == nil {
        return nil, err
    }
    result := &ListContainersResponse{rawResponse: resp.Response()}
    if err != nil {
        return result, err
    }
    defer resp.Response().Body.Close()
    b, err := ioutil.ReadAll(resp.Response().Body)
    if err != nil {
        return result, NewResponseError(err, resp.Response(), "failed to read response body")
    }
    if len(b) > 0 {
        b = removeBOM(b)
        err = xml.Unmarshal(b, result)
        if err != nil {
            return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body")
        }
    }
    return result, nil
}

// SetProperties sets properties for a storage account's Blob service endpoint, including properties for Storage
// Analytics and CORS (Cross-Origin Resource Sharing) rules
//
// storageServiceProperties is the StorageService properties. timeout is the timeout parameter is expressed in seconds.
// For more information, see <a
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
// Timeouts for Blob Service Operations.</a> requestID is provides a client-generated, opaque value with a 1 KB
// character limit that is recorded in the analytics logs when storage analytics logging is enabled.
func (client serviceClient) SetProperties(ctx context.Context, storageServiceProperties StorageServiceProperties, timeout *int32, requestID *string) (*ServiceSetPropertiesResponse, error) {
    if err := validate([]validation{
        {targetValue: storageServiceProperties,
            constraints: []constraint{{target: "storageServiceProperties.Logging", name: null, rule: false,
                chain: []constraint{{target: "storageServiceProperties.Logging.RetentionPolicy", name: null, rule: true,
                    chain: []constraint{{target: "storageServiceProperties.Logging.RetentionPolicy.Days", name: null, rule: false,
                        chain: []constraint{{target: "storageServiceProperties.Logging.RetentionPolicy.Days", name: inclusiveMinimum, rule: 1, chain: nil}}},
                    }},
                }},
                {target: "storageServiceProperties.HourMetrics", name: null, rule: false,
                    chain: []constraint{{target: "storageServiceProperties.HourMetrics.RetentionPolicy", name: null, rule: false,
                        chain: []constraint{{target: "storageServiceProperties.HourMetrics.RetentionPolicy.Days", name: null, rule: false,
                            chain: []constraint{{target: "storageServiceProperties.HourMetrics.RetentionPolicy.Days", name: inclusiveMinimum, rule: 1, chain: nil}}},
                        }},
                    }},
                {target: "storageServiceProperties.MinuteMetrics", name: null, rule: false,
                    chain: []constraint{{target: "storageServiceProperties.MinuteMetrics.RetentionPolicy", name: null, rule: false,
                        chain: []constraint{{target: "storageServiceProperties.MinuteMetrics.RetentionPolicy.Days", name: null, rule: false,
                            chain: []constraint{{target: "storageServiceProperties.MinuteMetrics.RetentionPolicy.Days", name: inclusiveMinimum, rule: 1, chain: nil}}},
                        }},
                    }},
                {target: "storageServiceProperties.DeleteRetentionPolicy", name: null, rule: false,
                    chain: []constraint{{target: "storageServiceProperties.DeleteRetentionPolicy.Days", name: null, rule: false,
                        chain: []constraint{{target: "storageServiceProperties.DeleteRetentionPolicy.Days", name: inclusiveMinimum, rule: 1, chain: nil}}},
                    }}}},
        {targetValue: timeout,
            constraints: []constraint{{target: "timeout", name: null, rule: false,
                chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
        return nil, err
    }
    req, err := client.setPropertiesPreparer(storageServiceProperties, timeout, requestID)
    if err != nil {
        return nil, err
    }
    resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.setPropertiesResponder}, req)
    if err != nil {
        return nil, err
    }
    return resp.(*ServiceSetPropertiesResponse), err
}

// setPropertiesPreparer prepares the SetProperties request.
func (client serviceClient) setPropertiesPreparer(storageServiceProperties StorageServiceProperties, timeout *int32, requestID *string) (pipeline.Request, error) {
    req, err := pipeline.NewRequest("PUT", client.url, nil)
    if err != nil {
        return req, pipeline.NewError(err, "failed to create request")
    }
    params := req.URL.Query()
    if timeout != nil {
        params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
    }
    params.Set("restype", "service")
    params.Set("comp", "properties")
    req.URL.RawQuery = params.Encode()
    req.Header.Set("x-ms-version", ServiceVersion)
    if requestID != nil {
        req.Header.Set("x-ms-client-request-id", *requestID)
    }
    b, err := xml.Marshal(storageServiceProperties)
    if err != nil {
        return req, pipeline.NewError(err, "failed to marshal request body")
    }
    req.Header.Set("Content-Type", "application/xml")
    err = req.SetBody(bytes.NewReader(b))
    if err != nil {
        return req, pipeline.NewError(err, "failed to set request body")
    }
    return req, nil
}

// setPropertiesResponder handles the response to the SetProperties request.
func (client serviceClient) setPropertiesResponder(resp pipeline.Response) (pipeline.Response, error) {
    err := validateResponse(resp, http.StatusOK, http.StatusAccepted)
    if resp == nil {
        return nil, err
    }
    io.Copy(ioutil.Discard, resp.Response().Body)
    resp.Response().Body.Close()
    return &ServiceSetPropertiesResponse{rawResponse: resp.Response()}, err
}