1package azblob
2
3// Code generated by Microsoft (R) AutoRest Code Generator.
4// Changes may cause incorrect behavior and will be lost if the code is regenerated.
5
6import (
7	"bytes"
8	"context"
9	"encoding/xml"
10	"github.com/Azure/azure-pipeline-go/pipeline"
11	"io"
12	"io/ioutil"
13	"net/http"
14	"net/url"
15	"strconv"
16	"time"
17)
18
19// containerClient is the client for the Container methods of the Azblob service.
20type containerClient struct {
21	managementClient
22}
23
24// newContainerClient creates an instance of the containerClient client.
25func newContainerClient(url url.URL, p pipeline.Pipeline) containerClient {
26	return containerClient{newManagementClient(url, p)}
27}
28
29// AcquireLease [Update] establishes and manages a lock on a container for delete operations. The lock duration can be
30// 15 to 60 seconds, or can be infinite
31//
32// timeout is the timeout parameter is expressed in seconds. For more information, see <a
33// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
34// Timeouts for Blob Service Operations.</a> duration is specifies the duration of the lease, in seconds, or negative
35// one (-1) for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration
36// cannot be changed using renew or change. proposedLeaseID is proposed lease ID, in a GUID string format. The Blob
37// service returns 400 (Invalid request) if the proposed lease ID is not in the correct format. See Guid Constructor
38// (String) for a list of valid GUID string formats. ifModifiedSince is specify this header value to operate only on a
39// blob if it has been modified since the specified date/time. ifUnmodifiedSince is specify this header value to
40// operate only on a blob if it has not been modified since the specified date/time. requestID is provides a
41// client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage
42// analytics logging is enabled.
43func (client containerClient) AcquireLease(ctx context.Context, timeout *int32, duration *int32, proposedLeaseID *string, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, requestID *string) (*ContainerAcquireLeaseResponse, error) {
44	if err := validate([]validation{
45		{targetValue: timeout,
46			constraints: []constraint{{target: "timeout", name: null, rule: false,
47				chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
48		return nil, err
49	}
50	req, err := client.acquireLeasePreparer(timeout, duration, proposedLeaseID, ifModifiedSince, ifUnmodifiedSince, requestID)
51	if err != nil {
52		return nil, err
53	}
54	resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.acquireLeaseResponder}, req)
55	if err != nil {
56		return nil, err
57	}
58	return resp.(*ContainerAcquireLeaseResponse), err
59}
60
61// acquireLeasePreparer prepares the AcquireLease request.
62func (client containerClient) acquireLeasePreparer(timeout *int32, duration *int32, proposedLeaseID *string, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, requestID *string) (pipeline.Request, error) {
63	req, err := pipeline.NewRequest("PUT", client.url, nil)
64	if err != nil {
65		return req, pipeline.NewError(err, "failed to create request")
66	}
67	params := req.URL.Query()
68	if timeout != nil {
69		params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
70	}
71	params.Set("comp", "lease")
72	params.Set("restype", "container")
73	req.URL.RawQuery = params.Encode()
74	if duration != nil {
75		req.Header.Set("x-ms-lease-duration", strconv.FormatInt(int64(*duration), 10))
76	}
77	if proposedLeaseID != nil {
78		req.Header.Set("x-ms-proposed-lease-id", *proposedLeaseID)
79	}
80	if ifModifiedSince != nil {
81		req.Header.Set("If-Modified-Since", (*ifModifiedSince).In(gmt).Format(time.RFC1123))
82	}
83	if ifUnmodifiedSince != nil {
84		req.Header.Set("If-Unmodified-Since", (*ifUnmodifiedSince).In(gmt).Format(time.RFC1123))
85	}
86	req.Header.Set("x-ms-version", ServiceVersion)
87	if requestID != nil {
88		req.Header.Set("x-ms-client-request-id", *requestID)
89	}
90	req.Header.Set("x-ms-lease-action", "acquire")
91	return req, nil
92}
93
94// acquireLeaseResponder handles the response to the AcquireLease request.
95func (client containerClient) acquireLeaseResponder(resp pipeline.Response) (pipeline.Response, error) {
96	err := validateResponse(resp, http.StatusOK, http.StatusCreated)
97	if resp == nil {
98		return nil, err
99	}
100	io.Copy(ioutil.Discard, resp.Response().Body)
101	resp.Response().Body.Close()
102	return &ContainerAcquireLeaseResponse{rawResponse: resp.Response()}, err
103}
104
105// BreakLease [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15
106// to 60 seconds, or can be infinite
107//
108// timeout is the timeout parameter is expressed in seconds. For more information, see <a
109// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
110// Timeouts for Blob Service Operations.</a> breakPeriod is for a break operation, proposed duration the lease should
111// continue before it is broken, in seconds, between 0 and 60. This break period is only used if it is shorter than the
112// time remaining on the lease. If longer, the time remaining on the lease is used. A new lease will not be available
113// before the break period has expired, but the lease may be held for longer than the break period. If this header does
114// not appear with a break operation, a fixed-duration lease breaks after the remaining lease period elapses, and an
115// infinite lease breaks immediately. ifModifiedSince is specify this header value to operate only on a blob if it has
116// been modified since the specified date/time. ifUnmodifiedSince is specify this header value to operate only on a
117// blob if it has not been modified since the specified date/time. requestID is provides a client-generated, opaque
118// value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled.
119func (client containerClient) BreakLease(ctx context.Context, timeout *int32, breakPeriod *int32, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, requestID *string) (*ContainerBreakLeaseResponse, error) {
120	if err := validate([]validation{
121		{targetValue: timeout,
122			constraints: []constraint{{target: "timeout", name: null, rule: false,
123				chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
124		return nil, err
125	}
126	req, err := client.breakLeasePreparer(timeout, breakPeriod, ifModifiedSince, ifUnmodifiedSince, requestID)
127	if err != nil {
128		return nil, err
129	}
130	resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.breakLeaseResponder}, req)
131	if err != nil {
132		return nil, err
133	}
134	return resp.(*ContainerBreakLeaseResponse), err
135}
136
137// breakLeasePreparer prepares the BreakLease request.
138func (client containerClient) breakLeasePreparer(timeout *int32, breakPeriod *int32, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, requestID *string) (pipeline.Request, error) {
139	req, err := pipeline.NewRequest("PUT", client.url, nil)
140	if err != nil {
141		return req, pipeline.NewError(err, "failed to create request")
142	}
143	params := req.URL.Query()
144	if timeout != nil {
145		params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
146	}
147	params.Set("comp", "lease")
148	params.Set("restype", "container")
149	req.URL.RawQuery = params.Encode()
150	if breakPeriod != nil {
151		req.Header.Set("x-ms-lease-break-period", strconv.FormatInt(int64(*breakPeriod), 10))
152	}
153	if ifModifiedSince != nil {
154		req.Header.Set("If-Modified-Since", (*ifModifiedSince).In(gmt).Format(time.RFC1123))
155	}
156	if ifUnmodifiedSince != nil {
157		req.Header.Set("If-Unmodified-Since", (*ifUnmodifiedSince).In(gmt).Format(time.RFC1123))
158	}
159	req.Header.Set("x-ms-version", ServiceVersion)
160	if requestID != nil {
161		req.Header.Set("x-ms-client-request-id", *requestID)
162	}
163	req.Header.Set("x-ms-lease-action", "break")
164	return req, nil
165}
166
167// breakLeaseResponder handles the response to the BreakLease request.
168func (client containerClient) breakLeaseResponder(resp pipeline.Response) (pipeline.Response, error) {
169	err := validateResponse(resp, http.StatusOK, http.StatusAccepted)
170	if resp == nil {
171		return nil, err
172	}
173	io.Copy(ioutil.Discard, resp.Response().Body)
174	resp.Response().Body.Close()
175	return &ContainerBreakLeaseResponse{rawResponse: resp.Response()}, err
176}
177
178// ChangeLease [Update] establishes and manages a lock on a container for delete operations. The lock duration can be
179// 15 to 60 seconds, or can be infinite
180//
181// leaseID is specifies the current lease ID on the resource. proposedLeaseID is proposed lease ID, in a GUID string
182// format. The Blob service returns 400 (Invalid request) if the proposed lease ID is not in the correct format. See
183// Guid Constructor (String) for a list of valid GUID string formats. timeout is the timeout parameter is expressed in
184// seconds. For more information, see <a
185// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
186// Timeouts for Blob Service Operations.</a> ifModifiedSince is specify this header value to operate only on a blob if
187// it has been modified since the specified date/time. ifUnmodifiedSince is specify this header value to operate only
188// on a blob if it has not been modified since the specified date/time. requestID is provides a client-generated,
189// opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is
190// enabled.
191func (client containerClient) ChangeLease(ctx context.Context, leaseID string, proposedLeaseID string, timeout *int32, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, requestID *string) (*ContainerChangeLeaseResponse, error) {
192	if err := validate([]validation{
193		{targetValue: timeout,
194			constraints: []constraint{{target: "timeout", name: null, rule: false,
195				chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
196		return nil, err
197	}
198	req, err := client.changeLeasePreparer(leaseID, proposedLeaseID, timeout, ifModifiedSince, ifUnmodifiedSince, requestID)
199	if err != nil {
200		return nil, err
201	}
202	resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.changeLeaseResponder}, req)
203	if err != nil {
204		return nil, err
205	}
206	return resp.(*ContainerChangeLeaseResponse), err
207}
208
209// changeLeasePreparer prepares the ChangeLease request.
210func (client containerClient) changeLeasePreparer(leaseID string, proposedLeaseID string, timeout *int32, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, requestID *string) (pipeline.Request, error) {
211	req, err := pipeline.NewRequest("PUT", client.url, nil)
212	if err != nil {
213		return req, pipeline.NewError(err, "failed to create request")
214	}
215	params := req.URL.Query()
216	if timeout != nil {
217		params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
218	}
219	params.Set("comp", "lease")
220	params.Set("restype", "container")
221	req.URL.RawQuery = params.Encode()
222	req.Header.Set("x-ms-lease-id", leaseID)
223	req.Header.Set("x-ms-proposed-lease-id", proposedLeaseID)
224	if ifModifiedSince != nil {
225		req.Header.Set("If-Modified-Since", (*ifModifiedSince).In(gmt).Format(time.RFC1123))
226	}
227	if ifUnmodifiedSince != nil {
228		req.Header.Set("If-Unmodified-Since", (*ifUnmodifiedSince).In(gmt).Format(time.RFC1123))
229	}
230	req.Header.Set("x-ms-version", ServiceVersion)
231	if requestID != nil {
232		req.Header.Set("x-ms-client-request-id", *requestID)
233	}
234	req.Header.Set("x-ms-lease-action", "change")
235	return req, nil
236}
237
238// changeLeaseResponder handles the response to the ChangeLease request.
239func (client containerClient) changeLeaseResponder(resp pipeline.Response) (pipeline.Response, error) {
240	err := validateResponse(resp, http.StatusOK)
241	if resp == nil {
242		return nil, err
243	}
244	io.Copy(ioutil.Discard, resp.Response().Body)
245	resp.Response().Body.Close()
246	return &ContainerChangeLeaseResponse{rawResponse: resp.Response()}, err
247}
248
249// Create creates a new container under the specified account. If the container with the same name already exists, the
250// operation fails
251//
252// timeout is the timeout parameter is expressed in seconds. For more information, see <a
253// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
254// Timeouts for Blob Service Operations.</a> metadata is optional. Specifies a user-defined name-value pair associated
255// with the blob. If no name-value pairs are specified, the operation will copy the metadata from the source blob or
256// file to the destination blob. If one or more name-value pairs are specified, the destination blob is created with
257// the specified metadata, and metadata is not copied from the source blob or file. Note that beginning with version
258// 2009-09-19, metadata names must adhere to the naming rules for C# identifiers. See Naming and Referencing
259// Containers, Blobs, and Metadata for more information. access is specifies whether data in the container may be
260// accessed publicly and the level of access requestID is provides a client-generated, opaque value with a 1 KB
261// character limit that is recorded in the analytics logs when storage analytics logging is enabled.
262func (client containerClient) Create(ctx context.Context, timeout *int32, metadata map[string]string, access PublicAccessType, requestID *string) (*ContainerCreateResponse, error) {
263	if err := validate([]validation{
264		{targetValue: timeout,
265			constraints: []constraint{{target: "timeout", name: null, rule: false,
266				chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
267		return nil, err
268	}
269	req, err := client.createPreparer(timeout, metadata, access, requestID)
270	if err != nil {
271		return nil, err
272	}
273	resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.createResponder}, req)
274	if err != nil {
275		return nil, err
276	}
277	return resp.(*ContainerCreateResponse), err
278}
279
280// createPreparer prepares the Create request.
281func (client containerClient) createPreparer(timeout *int32, metadata map[string]string, access PublicAccessType, requestID *string) (pipeline.Request, error) {
282	req, err := pipeline.NewRequest("PUT", client.url, nil)
283	if err != nil {
284		return req, pipeline.NewError(err, "failed to create request")
285	}
286	params := req.URL.Query()
287	if timeout != nil {
288		params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
289	}
290	params.Set("restype", "container")
291	req.URL.RawQuery = params.Encode()
292	if metadata != nil {
293		for k, v := range metadata {
294			req.Header.Set("x-ms-meta-"+k, v)
295		}
296	}
297	if access != PublicAccessNone {
298		req.Header.Set("x-ms-blob-public-access", string(access))
299	}
300	req.Header.Set("x-ms-version", ServiceVersion)
301	if requestID != nil {
302		req.Header.Set("x-ms-client-request-id", *requestID)
303	}
304	return req, nil
305}
306
307// createResponder handles the response to the Create request.
308func (client containerClient) createResponder(resp pipeline.Response) (pipeline.Response, error) {
309	err := validateResponse(resp, http.StatusOK, http.StatusCreated)
310	if resp == nil {
311		return nil, err
312	}
313	io.Copy(ioutil.Discard, resp.Response().Body)
314	resp.Response().Body.Close()
315	return &ContainerCreateResponse{rawResponse: resp.Response()}, err
316}
317
318// Delete operation marks the specified container for deletion. The container and any blobs contained within it are
319// later deleted during garbage collection
320//
321// timeout is the timeout parameter is expressed in seconds. For more information, see <a
322// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
323// Timeouts for Blob Service Operations.</a> leaseID is if specified, the operation only succeeds if the resource's
324// lease is active and matches this ID. ifModifiedSince is specify this header value to operate only on a blob if it
325// has been modified since the specified date/time. ifUnmodifiedSince is specify this header value to operate only on a
326// blob if it has not been modified since the specified date/time. requestID is provides a client-generated, opaque
327// value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled.
328func (client containerClient) Delete(ctx context.Context, timeout *int32, leaseID *string, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, requestID *string) (*ContainerDeleteResponse, error) {
329	if err := validate([]validation{
330		{targetValue: timeout,
331			constraints: []constraint{{target: "timeout", name: null, rule: false,
332				chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
333		return nil, err
334	}
335	req, err := client.deletePreparer(timeout, leaseID, ifModifiedSince, ifUnmodifiedSince, requestID)
336	if err != nil {
337		return nil, err
338	}
339	resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.deleteResponder}, req)
340	if err != nil {
341		return nil, err
342	}
343	return resp.(*ContainerDeleteResponse), err
344}
345
346// deletePreparer prepares the Delete request.
347func (client containerClient) deletePreparer(timeout *int32, leaseID *string, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, requestID *string) (pipeline.Request, error) {
348	req, err := pipeline.NewRequest("DELETE", client.url, nil)
349	if err != nil {
350		return req, pipeline.NewError(err, "failed to create request")
351	}
352	params := req.URL.Query()
353	if timeout != nil {
354		params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
355	}
356	params.Set("restype", "container")
357	req.URL.RawQuery = params.Encode()
358	if leaseID != nil {
359		req.Header.Set("x-ms-lease-id", *leaseID)
360	}
361	if ifModifiedSince != nil {
362		req.Header.Set("If-Modified-Since", (*ifModifiedSince).In(gmt).Format(time.RFC1123))
363	}
364	if ifUnmodifiedSince != nil {
365		req.Header.Set("If-Unmodified-Since", (*ifUnmodifiedSince).In(gmt).Format(time.RFC1123))
366	}
367	req.Header.Set("x-ms-version", ServiceVersion)
368	if requestID != nil {
369		req.Header.Set("x-ms-client-request-id", *requestID)
370	}
371	return req, nil
372}
373
374// deleteResponder handles the response to the Delete request.
375func (client containerClient) deleteResponder(resp pipeline.Response) (pipeline.Response, error) {
376	err := validateResponse(resp, http.StatusOK, http.StatusAccepted)
377	if resp == nil {
378		return nil, err
379	}
380	io.Copy(ioutil.Discard, resp.Response().Body)
381	resp.Response().Body.Close()
382	return &ContainerDeleteResponse{rawResponse: resp.Response()}, err
383}
384
385// GetAccessPolicy gets the permissions for the specified container. The permissions indicate whether container data
386// may be accessed publicly.
387//
388// timeout is the timeout parameter is expressed in seconds. For more information, see <a
389// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
390// Timeouts for Blob Service Operations.</a> leaseID is if specified, the operation only succeeds if the resource's
391// lease is active and matches this ID. requestID is provides a client-generated, opaque value with a 1 KB character
392// limit that is recorded in the analytics logs when storage analytics logging is enabled.
393func (client containerClient) GetAccessPolicy(ctx context.Context, timeout *int32, leaseID *string, requestID *string) (*SignedIdentifiers, error) {
394	if err := validate([]validation{
395		{targetValue: timeout,
396			constraints: []constraint{{target: "timeout", name: null, rule: false,
397				chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
398		return nil, err
399	}
400	req, err := client.getAccessPolicyPreparer(timeout, leaseID, requestID)
401	if err != nil {
402		return nil, err
403	}
404	resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.getAccessPolicyResponder}, req)
405	if err != nil {
406		return nil, err
407	}
408	return resp.(*SignedIdentifiers), err
409}
410
411// getAccessPolicyPreparer prepares the GetAccessPolicy request.
412func (client containerClient) getAccessPolicyPreparer(timeout *int32, leaseID *string, requestID *string) (pipeline.Request, error) {
413	req, err := pipeline.NewRequest("GET", client.url, nil)
414	if err != nil {
415		return req, pipeline.NewError(err, "failed to create request")
416	}
417	params := req.URL.Query()
418	if timeout != nil {
419		params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
420	}
421	params.Set("restype", "container")
422	params.Set("comp", "acl")
423	req.URL.RawQuery = params.Encode()
424	if leaseID != nil {
425		req.Header.Set("x-ms-lease-id", *leaseID)
426	}
427	req.Header.Set("x-ms-version", ServiceVersion)
428	if requestID != nil {
429		req.Header.Set("x-ms-client-request-id", *requestID)
430	}
431	return req, nil
432}
433
434// getAccessPolicyResponder handles the response to the GetAccessPolicy request.
435func (client containerClient) getAccessPolicyResponder(resp pipeline.Response) (pipeline.Response, error) {
436	err := validateResponse(resp, http.StatusOK)
437	if resp == nil {
438		return nil, err
439	}
440	result := &SignedIdentifiers{rawResponse: resp.Response()}
441	if err != nil {
442		return result, err
443	}
444	defer resp.Response().Body.Close()
445	b, err := ioutil.ReadAll(resp.Response().Body)
446	if err != nil {
447		return result, err
448	}
449	if len(b) > 0 {
450		b = removeBOM(b)
451		err = xml.Unmarshal(b, result)
452		if err != nil {
453			return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body")
454		}
455	}
456	return result, nil
457}
458
459// GetAccountInfo returns the sku name and account kind
460func (client containerClient) GetAccountInfo(ctx context.Context) (*ContainerGetAccountInfoResponse, error) {
461	req, err := client.getAccountInfoPreparer()
462	if err != nil {
463		return nil, err
464	}
465	resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.getAccountInfoResponder}, req)
466	if err != nil {
467		return nil, err
468	}
469	return resp.(*ContainerGetAccountInfoResponse), err
470}
471
472// getAccountInfoPreparer prepares the GetAccountInfo request.
473func (client containerClient) getAccountInfoPreparer() (pipeline.Request, error) {
474	req, err := pipeline.NewRequest("GET", client.url, nil)
475	if err != nil {
476		return req, pipeline.NewError(err, "failed to create request")
477	}
478	params := req.URL.Query()
479	params.Set("restype", "account")
480	params.Set("comp", "properties")
481	req.URL.RawQuery = params.Encode()
482	req.Header.Set("x-ms-version", ServiceVersion)
483	return req, nil
484}
485
486// getAccountInfoResponder handles the response to the GetAccountInfo request.
487func (client containerClient) getAccountInfoResponder(resp pipeline.Response) (pipeline.Response, error) {
488	err := validateResponse(resp, http.StatusOK)
489	if resp == nil {
490		return nil, err
491	}
492	io.Copy(ioutil.Discard, resp.Response().Body)
493	resp.Response().Body.Close()
494	return &ContainerGetAccountInfoResponse{rawResponse: resp.Response()}, err
495}
496
497// GetProperties returns all user-defined metadata and system properties for the specified container. The data returned
498// does not include the container's list of blobs
499//
500// timeout is the timeout parameter is expressed in seconds. For more information, see <a
501// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
502// Timeouts for Blob Service Operations.</a> leaseID is if specified, the operation only succeeds if the resource's
503// lease is active and matches this ID. requestID is provides a client-generated, opaque value with a 1 KB character
504// limit that is recorded in the analytics logs when storage analytics logging is enabled.
505func (client containerClient) GetProperties(ctx context.Context, timeout *int32, leaseID *string, requestID *string) (*ContainerGetPropertiesResponse, error) {
506	if err := validate([]validation{
507		{targetValue: timeout,
508			constraints: []constraint{{target: "timeout", name: null, rule: false,
509				chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
510		return nil, err
511	}
512	req, err := client.getPropertiesPreparer(timeout, leaseID, requestID)
513	if err != nil {
514		return nil, err
515	}
516	resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.getPropertiesResponder}, req)
517	if err != nil {
518		return nil, err
519	}
520	return resp.(*ContainerGetPropertiesResponse), err
521}
522
523// getPropertiesPreparer prepares the GetProperties request.
524func (client containerClient) getPropertiesPreparer(timeout *int32, leaseID *string, requestID *string) (pipeline.Request, error) {
525	req, err := pipeline.NewRequest("GET", client.url, nil)
526	if err != nil {
527		return req, pipeline.NewError(err, "failed to create request")
528	}
529	params := req.URL.Query()
530	if timeout != nil {
531		params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
532	}
533	params.Set("restype", "container")
534	req.URL.RawQuery = params.Encode()
535	if leaseID != nil {
536		req.Header.Set("x-ms-lease-id", *leaseID)
537	}
538	req.Header.Set("x-ms-version", ServiceVersion)
539	if requestID != nil {
540		req.Header.Set("x-ms-client-request-id", *requestID)
541	}
542	return req, nil
543}
544
545// getPropertiesResponder handles the response to the GetProperties request.
546func (client containerClient) getPropertiesResponder(resp pipeline.Response) (pipeline.Response, error) {
547	err := validateResponse(resp, http.StatusOK)
548	if resp == nil {
549		return nil, err
550	}
551	io.Copy(ioutil.Discard, resp.Response().Body)
552	resp.Response().Body.Close()
553	return &ContainerGetPropertiesResponse{rawResponse: resp.Response()}, err
554}
555
556// ListBlobFlatSegment [Update] The List Blobs operation returns a list of the blobs under the specified container
557//
558// prefix is filters the results to return only containers whose name begins with the specified prefix. marker is a
559// string value that identifies the portion of the list of containers to be returned with the next listing operation.
560// The operation returns the NextMarker value within the response body if the listing operation did not return all
561// containers remaining to be listed with the current page. The NextMarker value can be used as the value for the
562// marker parameter in a subsequent call to request the next page of list items. The marker value is opaque to the
563// client. maxresults is specifies the maximum number of containers to return. If the request does not specify
564// maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the
565// listing operation crosses a partition boundary, then the service will return a continuation token for retrieving the
566// remainder of the results. For this reason, it is possible that the service will return fewer results than specified
567// by maxresults, or than the default of 5000. include is include this parameter to specify one or more datasets to
568// include in the response. timeout is the timeout parameter is expressed in seconds. For more information, see <a
569// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
570// Timeouts for Blob Service Operations.</a> requestID is provides a client-generated, opaque value with a 1 KB
571// character limit that is recorded in the analytics logs when storage analytics logging is enabled.
572func (client containerClient) ListBlobFlatSegment(ctx context.Context, prefix *string, marker *string, maxresults *int32, include []ListBlobsIncludeItemType, timeout *int32, requestID *string) (*ListBlobsFlatSegmentResponse, error) {
573	if err := validate([]validation{
574		{targetValue: maxresults,
575			constraints: []constraint{{target: "maxresults", name: null, rule: false,
576				chain: []constraint{{target: "maxresults", name: inclusiveMinimum, rule: 1, chain: nil}}}}},
577		{targetValue: timeout,
578			constraints: []constraint{{target: "timeout", name: null, rule: false,
579				chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
580		return nil, err
581	}
582	req, err := client.listBlobFlatSegmentPreparer(prefix, marker, maxresults, include, timeout, requestID)
583	if err != nil {
584		return nil, err
585	}
586	resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.listBlobFlatSegmentResponder}, req)
587	if err != nil {
588		return nil, err
589	}
590	return resp.(*ListBlobsFlatSegmentResponse), err
591}
592
593// listBlobFlatSegmentPreparer prepares the ListBlobFlatSegment request.
594func (client containerClient) listBlobFlatSegmentPreparer(prefix *string, marker *string, maxresults *int32, include []ListBlobsIncludeItemType, timeout *int32, requestID *string) (pipeline.Request, error) {
595	req, err := pipeline.NewRequest("GET", client.url, nil)
596	if err != nil {
597		return req, pipeline.NewError(err, "failed to create request")
598	}
599	params := req.URL.Query()
600	if prefix != nil && len(*prefix) > 0 {
601		params.Set("prefix", *prefix)
602	}
603	if marker != nil && len(*marker) > 0 {
604		params.Set("marker", *marker)
605	}
606	if maxresults != nil {
607		params.Set("maxresults", strconv.FormatInt(int64(*maxresults), 10))
608	}
609	if include != nil && len(include) > 0 {
610		params.Set("include", joinConst(include, ","))
611	}
612	if timeout != nil {
613		params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
614	}
615	params.Set("restype", "container")
616	params.Set("comp", "list")
617	req.URL.RawQuery = params.Encode()
618	req.Header.Set("x-ms-version", ServiceVersion)
619	if requestID != nil {
620		req.Header.Set("x-ms-client-request-id", *requestID)
621	}
622	return req, nil
623}
624
625// listBlobFlatSegmentResponder handles the response to the ListBlobFlatSegment request.
626func (client containerClient) listBlobFlatSegmentResponder(resp pipeline.Response) (pipeline.Response, error) {
627	err := validateResponse(resp, http.StatusOK)
628	if resp == nil {
629		return nil, err
630	}
631	result := &ListBlobsFlatSegmentResponse{rawResponse: resp.Response()}
632	if err != nil {
633		return result, err
634	}
635	defer resp.Response().Body.Close()
636	b, err := ioutil.ReadAll(resp.Response().Body)
637	if err != nil {
638		return result, err
639	}
640	if len(b) > 0 {
641		b = removeBOM(b)
642		err = xml.Unmarshal(b, result)
643		if err != nil {
644			return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body")
645		}
646	}
647	return result, nil
648}
649
650// ListBlobHierarchySegment [Update] The List Blobs operation returns a list of the blobs under the specified container
651//
652// delimiter is when the request includes this parameter, the operation returns a BlobPrefix element in the response
653// body that acts as a placeholder for all blobs whose names begin with the same substring up to the appearance of the
654// delimiter character. The delimiter may be a single character or a string. prefix is filters the results to return
655// only containers whose name begins with the specified prefix. marker is a string value that identifies the portion of
656// the list of containers to be returned with the next listing operation. The operation returns the NextMarker value
657// within the response body if the listing operation did not return all containers remaining to be listed with the
658// current page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request
659// the next page of list items. The marker value is opaque to the client. maxresults is specifies the maximum number of
660// containers to return. If the request does not specify maxresults, or specifies a value greater than 5000, the server
661// will return up to 5000 items. Note that if the listing operation crosses a partition boundary, then the service will
662// return a continuation token for retrieving the remainder of the results. For this reason, it is possible that the
663// service will return fewer results than specified by maxresults, or than the default of 5000. include is include this
664// parameter to specify one or more datasets to include in the response. timeout is the timeout parameter is expressed
665// in seconds. For more information, see <a
666// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
667// Timeouts for Blob Service Operations.</a> requestID is provides a client-generated, opaque value with a 1 KB
668// character limit that is recorded in the analytics logs when storage analytics logging is enabled.
669func (client containerClient) ListBlobHierarchySegment(ctx context.Context, delimiter string, prefix *string, marker *string, maxresults *int32, include []ListBlobsIncludeItemType, timeout *int32, requestID *string) (*ListBlobsHierarchySegmentResponse, error) {
670	if err := validate([]validation{
671		{targetValue: maxresults,
672			constraints: []constraint{{target: "maxresults", name: null, rule: false,
673				chain: []constraint{{target: "maxresults", name: inclusiveMinimum, rule: 1, chain: nil}}}}},
674		{targetValue: timeout,
675			constraints: []constraint{{target: "timeout", name: null, rule: false,
676				chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
677		return nil, err
678	}
679	req, err := client.listBlobHierarchySegmentPreparer(delimiter, prefix, marker, maxresults, include, timeout, requestID)
680	if err != nil {
681		return nil, err
682	}
683	resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.listBlobHierarchySegmentResponder}, req)
684	if err != nil {
685		return nil, err
686	}
687	return resp.(*ListBlobsHierarchySegmentResponse), err
688}
689
690// listBlobHierarchySegmentPreparer prepares the ListBlobHierarchySegment request.
691func (client containerClient) listBlobHierarchySegmentPreparer(delimiter string, prefix *string, marker *string, maxresults *int32, include []ListBlobsIncludeItemType, timeout *int32, requestID *string) (pipeline.Request, error) {
692	req, err := pipeline.NewRequest("GET", client.url, nil)
693	if err != nil {
694		return req, pipeline.NewError(err, "failed to create request")
695	}
696	params := req.URL.Query()
697	if prefix != nil && len(*prefix) > 0 {
698		params.Set("prefix", *prefix)
699	}
700	params.Set("delimiter", delimiter)
701	if marker != nil && len(*marker) > 0 {
702		params.Set("marker", *marker)
703	}
704	if maxresults != nil {
705		params.Set("maxresults", strconv.FormatInt(int64(*maxresults), 10))
706	}
707	if include != nil && len(include) > 0 {
708		params.Set("include", joinConst(include, ","))
709	}
710	if timeout != nil {
711		params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
712	}
713	params.Set("restype", "container")
714	params.Set("comp", "list")
715	req.URL.RawQuery = params.Encode()
716	req.Header.Set("x-ms-version", ServiceVersion)
717	if requestID != nil {
718		req.Header.Set("x-ms-client-request-id", *requestID)
719	}
720	return req, nil
721}
722
723// listBlobHierarchySegmentResponder handles the response to the ListBlobHierarchySegment request.
724func (client containerClient) listBlobHierarchySegmentResponder(resp pipeline.Response) (pipeline.Response, error) {
725	err := validateResponse(resp, http.StatusOK)
726	if resp == nil {
727		return nil, err
728	}
729	result := &ListBlobsHierarchySegmentResponse{rawResponse: resp.Response()}
730	if err != nil {
731		return result, err
732	}
733	defer resp.Response().Body.Close()
734	b, err := ioutil.ReadAll(resp.Response().Body)
735	if err != nil {
736		return result, err
737	}
738	if len(b) > 0 {
739		b = removeBOM(b)
740		err = xml.Unmarshal(b, result)
741		if err != nil {
742			return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body")
743		}
744	}
745	return result, nil
746}
747
748// ReleaseLease [Update] establishes and manages a lock on a container for delete operations. The lock duration can be
749// 15 to 60 seconds, or can be infinite
750//
751// leaseID is specifies the current lease ID on the resource. timeout is the timeout parameter is expressed in seconds.
752// For more information, see <a
753// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
754// Timeouts for Blob Service Operations.</a> ifModifiedSince is specify this header value to operate only on a blob if
755// it has been modified since the specified date/time. ifUnmodifiedSince is specify this header value to operate only
756// on a blob if it has not been modified since the specified date/time. requestID is provides a client-generated,
757// opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is
758// enabled.
759func (client containerClient) ReleaseLease(ctx context.Context, leaseID string, timeout *int32, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, requestID *string) (*ContainerReleaseLeaseResponse, error) {
760	if err := validate([]validation{
761		{targetValue: timeout,
762			constraints: []constraint{{target: "timeout", name: null, rule: false,
763				chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
764		return nil, err
765	}
766	req, err := client.releaseLeasePreparer(leaseID, timeout, ifModifiedSince, ifUnmodifiedSince, requestID)
767	if err != nil {
768		return nil, err
769	}
770	resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.releaseLeaseResponder}, req)
771	if err != nil {
772		return nil, err
773	}
774	return resp.(*ContainerReleaseLeaseResponse), err
775}
776
777// releaseLeasePreparer prepares the ReleaseLease request.
778func (client containerClient) releaseLeasePreparer(leaseID string, timeout *int32, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, requestID *string) (pipeline.Request, error) {
779	req, err := pipeline.NewRequest("PUT", client.url, nil)
780	if err != nil {
781		return req, pipeline.NewError(err, "failed to create request")
782	}
783	params := req.URL.Query()
784	if timeout != nil {
785		params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
786	}
787	params.Set("comp", "lease")
788	params.Set("restype", "container")
789	req.URL.RawQuery = params.Encode()
790	req.Header.Set("x-ms-lease-id", leaseID)
791	if ifModifiedSince != nil {
792		req.Header.Set("If-Modified-Since", (*ifModifiedSince).In(gmt).Format(time.RFC1123))
793	}
794	if ifUnmodifiedSince != nil {
795		req.Header.Set("If-Unmodified-Since", (*ifUnmodifiedSince).In(gmt).Format(time.RFC1123))
796	}
797	req.Header.Set("x-ms-version", ServiceVersion)
798	if requestID != nil {
799		req.Header.Set("x-ms-client-request-id", *requestID)
800	}
801	req.Header.Set("x-ms-lease-action", "release")
802	return req, nil
803}
804
805// releaseLeaseResponder handles the response to the ReleaseLease request.
806func (client containerClient) releaseLeaseResponder(resp pipeline.Response) (pipeline.Response, error) {
807	err := validateResponse(resp, http.StatusOK)
808	if resp == nil {
809		return nil, err
810	}
811	io.Copy(ioutil.Discard, resp.Response().Body)
812	resp.Response().Body.Close()
813	return &ContainerReleaseLeaseResponse{rawResponse: resp.Response()}, err
814}
815
816// RenewLease [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15
817// to 60 seconds, or can be infinite
818//
819// leaseID is specifies the current lease ID on the resource. timeout is the timeout parameter is expressed in seconds.
820// For more information, see <a
821// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
822// Timeouts for Blob Service Operations.</a> ifModifiedSince is specify this header value to operate only on a blob if
823// it has been modified since the specified date/time. ifUnmodifiedSince is specify this header value to operate only
824// on a blob if it has not been modified since the specified date/time. requestID is provides a client-generated,
825// opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is
826// enabled.
827func (client containerClient) RenewLease(ctx context.Context, leaseID string, timeout *int32, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, requestID *string) (*ContainerRenewLeaseResponse, error) {
828	if err := validate([]validation{
829		{targetValue: timeout,
830			constraints: []constraint{{target: "timeout", name: null, rule: false,
831				chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
832		return nil, err
833	}
834	req, err := client.renewLeasePreparer(leaseID, timeout, ifModifiedSince, ifUnmodifiedSince, requestID)
835	if err != nil {
836		return nil, err
837	}
838	resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.renewLeaseResponder}, req)
839	if err != nil {
840		return nil, err
841	}
842	return resp.(*ContainerRenewLeaseResponse), err
843}
844
845// renewLeasePreparer prepares the RenewLease request.
846func (client containerClient) renewLeasePreparer(leaseID string, timeout *int32, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, requestID *string) (pipeline.Request, error) {
847	req, err := pipeline.NewRequest("PUT", client.url, nil)
848	if err != nil {
849		return req, pipeline.NewError(err, "failed to create request")
850	}
851	params := req.URL.Query()
852	if timeout != nil {
853		params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
854	}
855	params.Set("comp", "lease")
856	params.Set("restype", "container")
857	req.URL.RawQuery = params.Encode()
858	req.Header.Set("x-ms-lease-id", leaseID)
859	if ifModifiedSince != nil {
860		req.Header.Set("If-Modified-Since", (*ifModifiedSince).In(gmt).Format(time.RFC1123))
861	}
862	if ifUnmodifiedSince != nil {
863		req.Header.Set("If-Unmodified-Since", (*ifUnmodifiedSince).In(gmt).Format(time.RFC1123))
864	}
865	req.Header.Set("x-ms-version", ServiceVersion)
866	if requestID != nil {
867		req.Header.Set("x-ms-client-request-id", *requestID)
868	}
869	req.Header.Set("x-ms-lease-action", "renew")
870	return req, nil
871}
872
873// renewLeaseResponder handles the response to the RenewLease request.
874func (client containerClient) renewLeaseResponder(resp pipeline.Response) (pipeline.Response, error) {
875	err := validateResponse(resp, http.StatusOK)
876	if resp == nil {
877		return nil, err
878	}
879	io.Copy(ioutil.Discard, resp.Response().Body)
880	resp.Response().Body.Close()
881	return &ContainerRenewLeaseResponse{rawResponse: resp.Response()}, err
882}
883
884// SetAccessPolicy sets the permissions for the specified container. The permissions indicate whether blobs in a
885// container may be accessed publicly.
886//
887// containerACL is the acls for the container timeout is the timeout parameter is expressed in seconds. For more
888// information, see <a
889// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
890// Timeouts for Blob Service Operations.</a> leaseID is if specified, the operation only succeeds if the resource's
891// lease is active and matches this ID. access is specifies whether data in the container may be accessed publicly and
892// the level of access ifModifiedSince is specify this header value to operate only on a blob if it has been modified
893// since the specified date/time. ifUnmodifiedSince is specify this header value to operate only on a blob if it has
894// not been modified since the specified date/time. requestID is provides a client-generated, opaque value with a 1 KB
895// character limit that is recorded in the analytics logs when storage analytics logging is enabled.
896func (client containerClient) SetAccessPolicy(ctx context.Context, containerACL []SignedIdentifier, timeout *int32, leaseID *string, access PublicAccessType, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, requestID *string) (*ContainerSetAccessPolicyResponse, error) {
897	if err := validate([]validation{
898		{targetValue: timeout,
899			constraints: []constraint{{target: "timeout", name: null, rule: false,
900				chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
901		return nil, err
902	}
903	req, err := client.setAccessPolicyPreparer(containerACL, timeout, leaseID, access, ifModifiedSince, ifUnmodifiedSince, requestID)
904	if err != nil {
905		return nil, err
906	}
907	resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.setAccessPolicyResponder}, req)
908	if err != nil {
909		return nil, err
910	}
911	return resp.(*ContainerSetAccessPolicyResponse), err
912}
913
914// setAccessPolicyPreparer prepares the SetAccessPolicy request.
915func (client containerClient) setAccessPolicyPreparer(containerACL []SignedIdentifier, timeout *int32, leaseID *string, access PublicAccessType, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, requestID *string) (pipeline.Request, error) {
916	req, err := pipeline.NewRequest("PUT", client.url, nil)
917	if err != nil {
918		return req, pipeline.NewError(err, "failed to create request")
919	}
920	params := req.URL.Query()
921	if timeout != nil {
922		params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
923	}
924	params.Set("restype", "container")
925	params.Set("comp", "acl")
926	req.URL.RawQuery = params.Encode()
927	if leaseID != nil {
928		req.Header.Set("x-ms-lease-id", *leaseID)
929	}
930	if access != PublicAccessNone {
931		req.Header.Set("x-ms-blob-public-access", string(access))
932	}
933	if ifModifiedSince != nil {
934		req.Header.Set("If-Modified-Since", (*ifModifiedSince).In(gmt).Format(time.RFC1123))
935	}
936	if ifUnmodifiedSince != nil {
937		req.Header.Set("If-Unmodified-Since", (*ifUnmodifiedSince).In(gmt).Format(time.RFC1123))
938	}
939	req.Header.Set("x-ms-version", ServiceVersion)
940	if requestID != nil {
941		req.Header.Set("x-ms-client-request-id", *requestID)
942	}
943	b, err := xml.Marshal(SignedIdentifiers{Items: containerACL})
944	if err != nil {
945		return req, pipeline.NewError(err, "failed to marshal request body")
946	}
947	req.Header.Set("Content-Type", "application/xml")
948	err = req.SetBody(bytes.NewReader(b))
949	if err != nil {
950		return req, pipeline.NewError(err, "failed to set request body")
951	}
952	return req, nil
953}
954
955// setAccessPolicyResponder handles the response to the SetAccessPolicy request.
956func (client containerClient) setAccessPolicyResponder(resp pipeline.Response) (pipeline.Response, error) {
957	err := validateResponse(resp, http.StatusOK)
958	if resp == nil {
959		return nil, err
960	}
961	io.Copy(ioutil.Discard, resp.Response().Body)
962	resp.Response().Body.Close()
963	return &ContainerSetAccessPolicyResponse{rawResponse: resp.Response()}, err
964}
965
966// SetMetadata operation sets one or more user-defined name-value pairs for the specified container.
967//
968// timeout is the timeout parameter is expressed in seconds. For more information, see <a
969// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
970// Timeouts for Blob Service Operations.</a> leaseID is if specified, the operation only succeeds if the resource's
971// lease is active and matches this ID. metadata is optional. Specifies a user-defined name-value pair associated with
972// the blob. If no name-value pairs are specified, the operation will copy the metadata from the source blob or file to
973// the destination blob. If one or more name-value pairs are specified, the destination blob is created with the
974// specified metadata, and metadata is not copied from the source blob or file. Note that beginning with version
975// 2009-09-19, metadata names must adhere to the naming rules for C# identifiers. See Naming and Referencing
976// Containers, Blobs, and Metadata for more information. ifModifiedSince is specify this header value to operate only
977// on a blob if it has been modified since the specified date/time. requestID is provides a client-generated, opaque
978// value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled.
979func (client containerClient) SetMetadata(ctx context.Context, timeout *int32, leaseID *string, metadata map[string]string, ifModifiedSince *time.Time, requestID *string) (*ContainerSetMetadataResponse, error) {
980	if err := validate([]validation{
981		{targetValue: timeout,
982			constraints: []constraint{{target: "timeout", name: null, rule: false,
983				chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
984		return nil, err
985	}
986	req, err := client.setMetadataPreparer(timeout, leaseID, metadata, ifModifiedSince, requestID)
987	if err != nil {
988		return nil, err
989	}
990	resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.setMetadataResponder}, req)
991	if err != nil {
992		return nil, err
993	}
994	return resp.(*ContainerSetMetadataResponse), err
995}
996
997// setMetadataPreparer prepares the SetMetadata request.
998func (client containerClient) setMetadataPreparer(timeout *int32, leaseID *string, metadata map[string]string, ifModifiedSince *time.Time, requestID *string) (pipeline.Request, error) {
999	req, err := pipeline.NewRequest("PUT", client.url, nil)
1000	if err != nil {
1001		return req, pipeline.NewError(err, "failed to create request")
1002	}
1003	params := req.URL.Query()
1004	if timeout != nil {
1005		params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
1006	}
1007	params.Set("restype", "container")
1008	params.Set("comp", "metadata")
1009	req.URL.RawQuery = params.Encode()
1010	if leaseID != nil {
1011		req.Header.Set("x-ms-lease-id", *leaseID)
1012	}
1013	if metadata != nil {
1014		for k, v := range metadata {
1015			req.Header.Set("x-ms-meta-"+k, v)
1016		}
1017	}
1018	if ifModifiedSince != nil {
1019		req.Header.Set("If-Modified-Since", (*ifModifiedSince).In(gmt).Format(time.RFC1123))
1020	}
1021	req.Header.Set("x-ms-version", ServiceVersion)
1022	if requestID != nil {
1023		req.Header.Set("x-ms-client-request-id", *requestID)
1024	}
1025	return req, nil
1026}
1027
1028// setMetadataResponder handles the response to the SetMetadata request.
1029func (client containerClient) setMetadataResponder(resp pipeline.Response) (pipeline.Response, error) {
1030	err := validateResponse(resp, http.StatusOK)
1031	if resp == nil {
1032		return nil, err
1033	}
1034	io.Copy(ioutil.Discard, resp.Response().Body)
1035	resp.Response().Body.Close()
1036	return &ContainerSetMetadataResponse{rawResponse: resp.Response()}, err
1037}
1038