diff --git a/storage/2020-08-04/file/shares/create.go b/storage/2020-08-04/file/shares/create.go index 0124e81..9ef2f13 100644 --- a/storage/2020-08-04/file/shares/create.go +++ b/storage/2020-08-04/file/shares/create.go @@ -18,6 +18,9 @@ type CreateInput struct { // Must be greater than 0, and less than or equal to 5TB (5120). QuotaInGB int + // Specifies the enabled protocols on the share. If not specified, the default is SMB. + EnabledProtocol ShareProtocol + MetaData map[string]string } @@ -76,6 +79,10 @@ func (client Client) CreatePreparer(ctx context.Context, accountName, shareName "x-ms-share-quota": input.QuotaInGB, } + if input.EnabledProtocol != "" { + headers["x-ms-enabled-protocols"] = input.EnabledProtocol + } + headers = metadata.SetIntoHeaders(headers, input.MetaData) preparer := autorest.CreatePreparer( diff --git a/storage/2020-08-04/file/shares/lifecycle_test.go b/storage/2020-08-04/file/shares/lifecycle_test.go index fb3531a..bb5f818 100644 --- a/storage/2020-08-04/file/shares/lifecycle_test.go +++ b/storage/2020-08-04/file/shares/lifecycle_test.go @@ -293,3 +293,46 @@ func TestSharesLifecycleLargeQuota(t *testing.T) { t.Fatalf("Error deleting Share: %s", err) } } + +func TestSharesLifecycleNFSProtocol(t *testing.T) { + client, err := testhelpers.Build(t) + if err != nil { + t.Fatal(err) + } + ctx := context.TODO() + resourceGroup := fmt.Sprintf("acctestrg-%d", testhelpers.RandomInt()) + accountName := fmt.Sprintf("acctestsa%s", testhelpers.RandomString()) + shareName := fmt.Sprintf("share-%d", testhelpers.RandomInt()) + + testData, err := client.BuildTestResourcesWithSku(ctx, resourceGroup, accountName, storage.KindFileStorage, storage.SkuNamePremiumLRS) + if err != nil { + t.Fatal(err) + } + defer client.DestroyTestResources(ctx, resourceGroup, accountName) + + storageAuth := auth.NewSharedKeyLiteAuthorizer(accountName, testData.StorageAccountKey) + sharesClient := NewWithEnvironment(client.Environment) + sharesClient.Client = client.PrepareWithAuthorizer(sharesClient.Client, storageAuth) + + input := CreateInput{ + QuotaInGB: 1000, + EnabledProtocol: NFS, + } + _, err = sharesClient.Create(ctx, accountName, shareName, input) + if err != nil { + t.Fatalf("Error creating fileshare: %s", err) + } + + share, err := sharesClient.GetProperties(ctx, accountName, shareName) + if err != nil { + t.Fatalf("Error retrieving share: %s", err) + } + if share.EnabledProtocol != NFS { + t.Fatalf(`Expected enabled protocol to be "NFS" but got: %q`, share.EnabledProtocol) + } + + _, err = sharesClient.Delete(ctx, accountName, shareName, false) + if err != nil { + t.Fatalf("Error deleting Share: %s", err) + } +} diff --git a/storage/2020-08-04/file/shares/models.go b/storage/2020-08-04/file/shares/models.go index 31ef7c2..3272716 100644 --- a/storage/2020-08-04/file/shares/models.go +++ b/storage/2020-08-04/file/shares/models.go @@ -10,3 +10,13 @@ type AccessPolicy struct { Expiry string `xml:"Expiry"` Permission string `xml:"Permission"` } + +type ShareProtocol string + +const ( + // SMB indicates the share can be accessed by SMBv3.0, SMBv2.1 and REST. + SMB ShareProtocol = "SMB" + + // NFS indicates the share can be accessed by NFSv4.1. A premium account is required for this option. + NFS ShareProtocol = "NFS" +) diff --git a/storage/2020-08-04/file/shares/properties_get.go b/storage/2020-08-04/file/shares/properties_get.go index 95fa58d..6ff05cb 100644 --- a/storage/2020-08-04/file/shares/properties_get.go +++ b/storage/2020-08-04/file/shares/properties_get.go @@ -17,8 +17,9 @@ import ( type GetPropertiesResult struct { autorest.Response - MetaData map[string]string - ShareQuota int + MetaData map[string]string + ShareQuota int + EnabledProtocol ShareProtocol } // GetProperties returns the properties about the specified Storage Share @@ -100,6 +101,11 @@ func (client Client) GetPropertiesResponder(resp *http.Response) (result GetProp } result.ShareQuota = quota } + + protocolRaw := resp.Header.Get("x-ms-enabled-protocols") + if protocolRaw != "" { + result.EnabledProtocol = ShareProtocol(protocolRaw) + } } err = autorest.Respond(