1package filesystems 2 3import ( 4 "context" 5 "net/http" 6 7 "github.com/Azure/go-autorest/autorest" 8 "github.com/Azure/go-autorest/autorest/azure" 9 "github.com/Azure/go-autorest/autorest/validation" 10 "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" 11) 12 13type SetPropertiesInput struct { 14 // A map of base64-encoded strings to store as user-defined properties with the File System 15 // Note that items may only contain ASCII characters in the ISO-8859-1 character set. 16 // This automatically gets converted to a comma-separated list of name and 17 // value pairs before sending to the API 18 Properties map[string]string 19 20 // Optional - A date and time value. 21 // Specify this header to perform the operation only if the resource has been modified since the specified date and time. 22 IfModifiedSince *string 23 24 // Optional - A date and time value. 25 // Specify this header to perform the operation only if the resource has not been modified since the specified date and time. 26 IfUnmodifiedSince *string 27} 28 29// SetProperties sets the Properties for a Data Lake Store Gen2 FileSystem within a Storage Account 30func (client Client) SetProperties(ctx context.Context, accountName string, fileSystemName string, input SetPropertiesInput) (result autorest.Response, err error) { 31 if accountName == "" { 32 return result, validation.NewError("datalakestore.Client", "SetProperties", "`accountName` cannot be an empty string.") 33 } 34 if fileSystemName == "" { 35 return result, validation.NewError("datalakestore.Client", "SetProperties", "`fileSystemName` cannot be an empty string.") 36 } 37 38 req, err := client.SetPropertiesPreparer(ctx, accountName, fileSystemName, input) 39 if err != nil { 40 err = autorest.NewErrorWithError(err, "datalakestore.Client", "SetProperties", nil, "Failure preparing request") 41 return 42 } 43 44 resp, err := client.SetPropertiesSender(req) 45 if err != nil { 46 result = autorest.Response{Response: resp} 47 err = autorest.NewErrorWithError(err, "datalakestore.Client", "SetProperties", resp, "Failure sending request") 48 return 49 } 50 51 result, err = client.SetPropertiesResponder(resp) 52 if err != nil { 53 err = autorest.NewErrorWithError(err, "datalakestore.Client", "SetProperties", resp, "Failure responding to request") 54 } 55 56 return 57} 58 59// SetPropertiesPreparer prepares the SetProperties request. 60func (client Client) SetPropertiesPreparer(ctx context.Context, accountName string, fileSystemName string, input SetPropertiesInput) (*http.Request, error) { 61 pathParameters := map[string]interface{}{ 62 "fileSystemName": autorest.Encode("path", fileSystemName), 63 } 64 65 queryParameters := map[string]interface{}{ 66 "resource": autorest.Encode("query", "filesystem"), 67 } 68 69 headers := map[string]interface{}{ 70 "x-ms-properties": buildProperties(input.Properties), 71 "x-ms-version": APIVersion, 72 } 73 74 if input.IfModifiedSince != nil { 75 headers["If-Modified-Since"] = *input.IfModifiedSince 76 } 77 if input.IfUnmodifiedSince != nil { 78 headers["If-Unmodified-Since"] = *input.IfUnmodifiedSince 79 } 80 81 preparer := autorest.CreatePreparer( 82 autorest.AsPatch(), 83 autorest.WithBaseURL(endpoints.GetDataLakeStoreEndpoint(client.BaseURI, accountName)), 84 autorest.WithPathParameters("/{fileSystemName}", pathParameters), 85 autorest.WithQueryParameters(queryParameters), 86 autorest.WithHeaders(headers)) 87 88 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 89} 90 91// SetPropertiesSender sends the SetProperties request. The method will close the 92// http.Response Body if it receives an error. 93func (client Client) SetPropertiesSender(req *http.Request) (*http.Response, error) { 94 return autorest.SendWithSender(client, req, 95 azure.DoRetryWithRegistration(client.Client)) 96} 97 98// SetPropertiesResponder handles the response to the SetProperties request. The method always 99// closes the http.Response Body. 100func (client Client) SetPropertiesResponder(resp *http.Response) (result autorest.Response, err error) { 101 err = autorest.Respond( 102 resp, 103 client.ByInspecting(), 104 azure.WithErrorUnlessStatusCode(http.StatusOK), 105 autorest.ByClosing()) 106 result = autorest.Response{Response: resp} 107 108 return 109} 110