From 6e87916b7deb2ae377aa07b90ad9f7d17af24bab Mon Sep 17 00:00:00 2001
From: Azure SDK for Python bot <aspysdk2@microsoft.com>
Date: Wed, 17 Oct 2018 02:31:24 +0000
Subject: [PATCH] Generated from 88b84e1190765fe4ff954cb4309c3dee53a03f7b

[Storage] update Long Running operation
---
 .../preview/storage/mgmt/storage/models.go    |  13 ++
 .../2015-05-01-preview/storage/accounts.go    |   4 -
 .../2018-03-01-preview/storage/accounts.go    |   4 -
 .../mgmt/2015-06-15/storage/accounts.go       |   4 -
 .../mgmt/2016-01-01/storage/accounts.go       |   4 -
 .../mgmt/2016-05-01/storage/accounts.go       |   4 -
 .../mgmt/2016-12-01/storage/accounts.go       |   4 -
 .../mgmt/2017-06-01/storage/accounts.go       |   4 -
 .../mgmt/2017-10-01/storage/accounts.go       |   4 -
 .../mgmt/2018-02-01/storage/accounts.go       |   4 -
 .../mgmt/2018-07-01/storage/accounts.go       | 169 +++++++++++++++++-
 .../storage/mgmt/2018-07-01/storage/models.go |  50 ++++++
 12 files changed, 228 insertions(+), 40 deletions(-)

diff --git a/profiles/preview/storage/mgmt/storage/models.go b/profiles/preview/storage/mgmt/storage/models.go
index 1c4570404a4a..07373e687f0b 100644
--- a/profiles/preview/storage/mgmt/storage/models.go
+++ b/profiles/preview/storage/mgmt/storage/models.go
@@ -179,6 +179,14 @@ const (
 	QuotaID                     ReasonCode = original.QuotaID
 )
 
+type ReplicationStatus = original.ReplicationStatus
+
+const (
+	ReplicationStatusBootstrap   ReplicationStatus = original.ReplicationStatusBootstrap
+	ReplicationStatusLive        ReplicationStatus = original.ReplicationStatusLive
+	ReplicationStatusUnavailable ReplicationStatus = original.ReplicationStatusUnavailable
+)
+
 type Services = original.Services
 
 const (
@@ -258,6 +266,7 @@ type AccountPropertiesUpdateParameters = original.AccountPropertiesUpdateParamet
 type AccountRegenerateKeyParameters = original.AccountRegenerateKeyParameters
 type AccountSasParameters = original.AccountSasParameters
 type AccountsCreateFuture = original.AccountsCreateFuture
+type AccountsFailoverFuture = original.AccountsFailoverFuture
 type AccountUpdateParameters = original.AccountUpdateParameters
 type AzureEntityResource = original.AzureEntityResource
 type BlobContainer = original.BlobContainer
@@ -269,6 +278,7 @@ type Encryption = original.Encryption
 type EncryptionService = original.EncryptionService
 type EncryptionServices = original.EncryptionServices
 type Endpoints = original.Endpoints
+type GetLastSyncTimeResult = original.GetLastSyncTimeResult
 type Identity = original.Identity
 type ImmutabilityPolicy = original.ImmutabilityPolicy
 type ImmutabilityPolicyProperties = original.ImmutabilityPolicyProperties
@@ -389,6 +399,9 @@ func PossibleReasonValues() []Reason {
 func PossibleReasonCodeValues() []ReasonCode {
 	return original.PossibleReasonCodeValues()
 }
+func PossibleReplicationStatusValues() []ReplicationStatus {
+	return original.PossibleReplicationStatusValues()
+}
 func PossibleServicesValues() []Services {
 	return original.PossibleServicesValues()
 }
diff --git a/services/preview/storage/mgmt/2015-05-01-preview/storage/accounts.go b/services/preview/storage/mgmt/2015-05-01-preview/storage/accounts.go
index a9ba6ab6ce0a..9e1826a5a0eb 100644
--- a/services/preview/storage/mgmt/2015-05-01-preview/storage/accounts.go
+++ b/services/preview/storage/mgmt/2015-05-01-preview/storage/accounts.go
@@ -162,10 +162,6 @@ func (client AccountsClient) CreateSender(req *http.Request) (future AccountsCre
 	if err != nil {
 		return
 	}
-	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
-	if err != nil {
-		return
-	}
 	future.Future, err = azure.NewFutureFromResponse(resp)
 	return
 }
diff --git a/services/preview/storage/mgmt/2018-03-01-preview/storage/accounts.go b/services/preview/storage/mgmt/2018-03-01-preview/storage/accounts.go
index bbdeecf4b5a6..f4fdbc94d1ff 100644
--- a/services/preview/storage/mgmt/2018-03-01-preview/storage/accounts.go
+++ b/services/preview/storage/mgmt/2018-03-01-preview/storage/accounts.go
@@ -196,10 +196,6 @@ func (client AccountsClient) CreateSender(req *http.Request) (future AccountsCre
 	if err != nil {
 		return
 	}
-	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
-	if err != nil {
-		return
-	}
 	future.Future, err = azure.NewFutureFromResponse(resp)
 	return
 }
diff --git a/services/storage/mgmt/2015-06-15/storage/accounts.go b/services/storage/mgmt/2015-06-15/storage/accounts.go
index 5d357d59f142..47d1f291d6d0 100644
--- a/services/storage/mgmt/2015-06-15/storage/accounts.go
+++ b/services/storage/mgmt/2015-06-15/storage/accounts.go
@@ -184,10 +184,6 @@ func (client AccountsClient) CreateSender(req *http.Request) (future AccountsCre
 	if err != nil {
 		return
 	}
-	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
-	if err != nil {
-		return
-	}
 	future.Future, err = azure.NewFutureFromResponse(resp)
 	return
 }
diff --git a/services/storage/mgmt/2016-01-01/storage/accounts.go b/services/storage/mgmt/2016-01-01/storage/accounts.go
index b9d2cbd9915e..21085661a788 100644
--- a/services/storage/mgmt/2016-01-01/storage/accounts.go
+++ b/services/storage/mgmt/2016-01-01/storage/accounts.go
@@ -187,10 +187,6 @@ func (client AccountsClient) CreateSender(req *http.Request) (future AccountsCre
 	if err != nil {
 		return
 	}
-	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
-	if err != nil {
-		return
-	}
 	future.Future, err = azure.NewFutureFromResponse(resp)
 	return
 }
diff --git a/services/storage/mgmt/2016-05-01/storage/accounts.go b/services/storage/mgmt/2016-05-01/storage/accounts.go
index 70f89ad585c6..1b8217bd855a 100644
--- a/services/storage/mgmt/2016-05-01/storage/accounts.go
+++ b/services/storage/mgmt/2016-05-01/storage/accounts.go
@@ -192,10 +192,6 @@ func (client AccountsClient) CreateSender(req *http.Request) (future AccountsCre
 	if err != nil {
 		return
 	}
-	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
-	if err != nil {
-		return
-	}
 	future.Future, err = azure.NewFutureFromResponse(resp)
 	return
 }
diff --git a/services/storage/mgmt/2016-12-01/storage/accounts.go b/services/storage/mgmt/2016-12-01/storage/accounts.go
index fe1099e92432..cfb4a86c3e68 100644
--- a/services/storage/mgmt/2016-12-01/storage/accounts.go
+++ b/services/storage/mgmt/2016-12-01/storage/accounts.go
@@ -192,10 +192,6 @@ func (client AccountsClient) CreateSender(req *http.Request) (future AccountsCre
 	if err != nil {
 		return
 	}
-	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
-	if err != nil {
-		return
-	}
 	future.Future, err = azure.NewFutureFromResponse(resp)
 	return
 }
diff --git a/services/storage/mgmt/2017-06-01/storage/accounts.go b/services/storage/mgmt/2017-06-01/storage/accounts.go
index b32d14850815..6f4348f019a5 100644
--- a/services/storage/mgmt/2017-06-01/storage/accounts.go
+++ b/services/storage/mgmt/2017-06-01/storage/accounts.go
@@ -192,10 +192,6 @@ func (client AccountsClient) CreateSender(req *http.Request) (future AccountsCre
 	if err != nil {
 		return
 	}
-	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
-	if err != nil {
-		return
-	}
 	future.Future, err = azure.NewFutureFromResponse(resp)
 	return
 }
diff --git a/services/storage/mgmt/2017-10-01/storage/accounts.go b/services/storage/mgmt/2017-10-01/storage/accounts.go
index 56dc300ec18f..89ccc3c9564e 100644
--- a/services/storage/mgmt/2017-10-01/storage/accounts.go
+++ b/services/storage/mgmt/2017-10-01/storage/accounts.go
@@ -192,10 +192,6 @@ func (client AccountsClient) CreateSender(req *http.Request) (future AccountsCre
 	if err != nil {
 		return
 	}
-	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
-	if err != nil {
-		return
-	}
 	future.Future, err = azure.NewFutureFromResponse(resp)
 	return
 }
diff --git a/services/storage/mgmt/2018-02-01/storage/accounts.go b/services/storage/mgmt/2018-02-01/storage/accounts.go
index 5c2b4738c73c..24e51a685057 100644
--- a/services/storage/mgmt/2018-02-01/storage/accounts.go
+++ b/services/storage/mgmt/2018-02-01/storage/accounts.go
@@ -196,10 +196,6 @@ func (client AccountsClient) CreateSender(req *http.Request) (future AccountsCre
 	if err != nil {
 		return
 	}
-	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
-	if err != nil {
-		return
-	}
 	future.Future, err = azure.NewFutureFromResponse(resp)
 	return
 }
diff --git a/services/storage/mgmt/2018-07-01/storage/accounts.go b/services/storage/mgmt/2018-07-01/storage/accounts.go
index 1af73b7c9c89..8201ce17b8e5 100644
--- a/services/storage/mgmt/2018-07-01/storage/accounts.go
+++ b/services/storage/mgmt/2018-07-01/storage/accounts.go
@@ -196,10 +196,6 @@ func (client AccountsClient) CreateSender(req *http.Request) (future AccountsCre
 	if err != nil {
 		return
 	}
-	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
-	if err != nil {
-		return
-	}
 	future.Future, err = azure.NewFutureFromResponse(resp)
 	return
 }
@@ -298,6 +294,171 @@ func (client AccountsClient) DeleteResponder(resp *http.Response) (result autore
 	return
 }
 
+// Failover failover request can be triggered for a storage account in case of availability issues. The failover occurs
+// from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will
+// become primary after failover.
+// Parameters:
+// resourceGroupName - the name of the resource group within the user's subscription. The name is case
+// insensitive.
+// accountName - the name of the storage account within the specified resource group. Storage account names
+// must be between 3 and 24 characters in length and use numbers and lower-case letters only.
+func (client AccountsClient) Failover(ctx context.Context, resourceGroupName string, accountName string) (result AccountsFailoverFuture, err error) {
+	if err := validation.Validate([]validation.Validation{
+		{TargetValue: resourceGroupName,
+			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
+				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
+				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
+		{TargetValue: accountName,
+			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
+				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
+		{TargetValue: client.SubscriptionID,
+			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
+		return result, validation.NewError("storage.AccountsClient", "Failover", err.Error())
+	}
+
+	req, err := client.FailoverPreparer(ctx, resourceGroupName, accountName)
+	if err != nil {
+		err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Failover", nil, "Failure preparing request")
+		return
+	}
+
+	result, err = client.FailoverSender(req)
+	if err != nil {
+		err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Failover", result.Response(), "Failure sending request")
+		return
+	}
+
+	return
+}
+
+// FailoverPreparer prepares the Failover request.
+func (client AccountsClient) FailoverPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
+	pathParameters := map[string]interface{}{
+		"accountName":       autorest.Encode("path", accountName),
+		"resourceGroupName": autorest.Encode("path", resourceGroupName),
+		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
+	}
+
+	const APIVersion = "2018-07-01"
+	queryParameters := map[string]interface{}{
+		"api-version": APIVersion,
+	}
+
+	preparer := autorest.CreatePreparer(
+		autorest.AsPost(),
+		autorest.WithBaseURL(client.BaseURI),
+		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover", pathParameters),
+		autorest.WithQueryParameters(queryParameters))
+	return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// FailoverSender sends the Failover request. The method will close the
+// http.Response Body if it receives an error.
+func (client AccountsClient) FailoverSender(req *http.Request) (future AccountsFailoverFuture, err error) {
+	var resp *http.Response
+	resp, err = autorest.SendWithSender(client, req,
+		azure.DoRetryWithRegistration(client.Client))
+	if err != nil {
+		return
+	}
+	future.Future, err = azure.NewFutureFromResponse(resp)
+	return
+}
+
+// FailoverResponder handles the response to the Failover request. The method always
+// closes the http.Response Body.
+func (client AccountsClient) FailoverResponder(resp *http.Response) (result autorest.Response, err error) {
+	err = autorest.Respond(
+		resp,
+		client.ByInspecting(),
+		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+		autorest.ByClosing())
+	result.Response = resp
+	return
+}
+
+// GetLastSyncTime retrieve last sync time for his or her RA-GRS and GRS accounts.
+// Parameters:
+// resourceGroupName - the name of the resource group within the user's subscription. The name is case
+// insensitive.
+// accountName - the name of the storage account within the specified resource group. Storage account names
+// must be between 3 and 24 characters in length and use numbers and lower-case letters only.
+func (client AccountsClient) GetLastSyncTime(ctx context.Context, resourceGroupName string, accountName string) (result GetLastSyncTimeResult, err error) {
+	if err := validation.Validate([]validation.Validation{
+		{TargetValue: resourceGroupName,
+			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
+				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
+				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
+		{TargetValue: accountName,
+			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
+				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
+		{TargetValue: client.SubscriptionID,
+			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
+		return result, validation.NewError("storage.AccountsClient", "GetLastSyncTime", err.Error())
+	}
+
+	req, err := client.GetLastSyncTimePreparer(ctx, resourceGroupName, accountName)
+	if err != nil {
+		err = autorest.NewErrorWithError(err, "storage.AccountsClient", "GetLastSyncTime", nil, "Failure preparing request")
+		return
+	}
+
+	resp, err := client.GetLastSyncTimeSender(req)
+	if err != nil {
+		result.Response = autorest.Response{Response: resp}
+		err = autorest.NewErrorWithError(err, "storage.AccountsClient", "GetLastSyncTime", resp, "Failure sending request")
+		return
+	}
+
+	result, err = client.GetLastSyncTimeResponder(resp)
+	if err != nil {
+		err = autorest.NewErrorWithError(err, "storage.AccountsClient", "GetLastSyncTime", resp, "Failure responding to request")
+	}
+
+	return
+}
+
+// GetLastSyncTimePreparer prepares the GetLastSyncTime request.
+func (client AccountsClient) GetLastSyncTimePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
+	pathParameters := map[string]interface{}{
+		"accountName":       autorest.Encode("path", accountName),
+		"resourceGroupName": autorest.Encode("path", resourceGroupName),
+		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
+	}
+
+	const APIVersion = "2018-07-01"
+	queryParameters := map[string]interface{}{
+		"api-version": APIVersion,
+	}
+
+	preparer := autorest.CreatePreparer(
+		autorest.AsGet(),
+		autorest.WithBaseURL(client.BaseURI),
+		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/lastSyncTime", pathParameters),
+		autorest.WithQueryParameters(queryParameters))
+	return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// GetLastSyncTimeSender sends the GetLastSyncTime request. The method will close the
+// http.Response Body if it receives an error.
+func (client AccountsClient) GetLastSyncTimeSender(req *http.Request) (*http.Response, error) {
+	return autorest.SendWithSender(client, req,
+		azure.DoRetryWithRegistration(client.Client))
+}
+
+// GetLastSyncTimeResponder handles the response to the GetLastSyncTime request. The method always
+// closes the http.Response Body.
+func (client AccountsClient) GetLastSyncTimeResponder(resp *http.Response) (result GetLastSyncTimeResult, err error) {
+	err = autorest.Respond(
+		resp,
+		client.ByInspecting(),
+		azure.WithErrorUnlessStatusCode(http.StatusOK),
+		autorest.ByUnmarshallingJSON(&result),
+		autorest.ByClosing())
+	result.Response = autorest.Response{Response: resp}
+	return
+}
+
 // GetProperties returns the properties for the specified storage account including but not limited to name, SKU name,
 // location, and account status. The ListKeys operation should be used to retrieve storage keys.
 // Parameters:
diff --git a/services/storage/mgmt/2018-07-01/storage/models.go b/services/storage/mgmt/2018-07-01/storage/models.go
index 39f4d414d635..1be061573ac9 100644
--- a/services/storage/mgmt/2018-07-01/storage/models.go
+++ b/services/storage/mgmt/2018-07-01/storage/models.go
@@ -342,6 +342,23 @@ func PossibleReasonCodeValues() []ReasonCode {
 	return []ReasonCode{NotAvailableForSubscription, QuotaID}
 }
 
+// ReplicationStatus enumerates the values for replication status.
+type ReplicationStatus string
+
+const (
+	// ReplicationStatusBootstrap ...
+	ReplicationStatusBootstrap ReplicationStatus = "Bootstrap"
+	// ReplicationStatusLive ...
+	ReplicationStatusLive ReplicationStatus = "Live"
+	// ReplicationStatusUnavailable ...
+	ReplicationStatusUnavailable ReplicationStatus = "Unavailable"
+)
+
+// PossibleReplicationStatusValues returns an array of possible values for the ReplicationStatus const type.
+func PossibleReplicationStatusValues() []ReplicationStatus {
+	return []ReplicationStatus{ReplicationStatusBootstrap, ReplicationStatusLive, ReplicationStatusUnavailable}
+}
+
 // Services enumerates the values for services.
 type Services string
 
@@ -896,6 +913,8 @@ type AccountProperties struct {
 	NetworkRuleSet *NetworkRuleSet `json:"networkAcls,omitempty"`
 	// IsHnsEnabled - Account HierarchicalNamespace enabled if sets to true.
 	IsHnsEnabled *bool `json:"isHnsEnabled,omitempty"`
+	// FailoverInProgress - If the failover is in progress, the value will be true, otherwise, it will be null.
+	FailoverInProgress *bool `json:"failoverInProgress,omitempty"`
 }
 
 // AccountPropertiesCreateParameters the parameters used to create the storage account.
@@ -986,6 +1005,28 @@ func (future *AccountsCreateFuture) Result(client AccountsClient) (a Account, er
 	return
 }
 
+// AccountsFailoverFuture an abstraction for monitoring and retrieving the results of a long-running operation.
+type AccountsFailoverFuture struct {
+	azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *AccountsFailoverFuture) Result(client AccountsClient) (ar autorest.Response, err error) {
+	var done bool
+	done, err = future.Done(client)
+	if err != nil {
+		err = autorest.NewErrorWithError(err, "storage.AccountsFailoverFuture", "Result", future.Response(), "Polling failure")
+		return
+	}
+	if !done {
+		err = azure.NewAsyncOpIncompleteError("storage.AccountsFailoverFuture")
+		return
+	}
+	ar.Response = future.Response()
+	return
+}
+
 // AccountUpdateParameters the parameters that can be provided when updating the storage account properties.
 type AccountUpdateParameters struct {
 	// Sku - Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those sku names be updated to any other value.
@@ -1322,6 +1363,15 @@ type Endpoints struct {
 	Dfs *string `json:"dfs,omitempty"`
 }
 
+// GetLastSyncTimeResult the response from the get last synctime operation.
+type GetLastSyncTimeResult struct {
+	autorest.Response `json:"-"`
+	// Status - The status of the secondary location of the Storage Account. Live: Indicates that the secondary location is active and operational; Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress, this typically occurs when replication is first enabled; Unavailable: Indicates that the secondary location is temporarily unavailable. Possible values include: 'ReplicationStatusLive', 'ReplicationStatusBootstrap', 'ReplicationStatusUnavailable'
+	Status ReplicationStatus `json:"status,omitempty"`
+	// LastSyncTime - All primary writes preceding this value are guaranteed to be replicated to secondary. Primary writes after this point in time may or may not be replicated. It is the minimum last sync time of the account’s Blob/Table/Queue/File endpoints. The value may be account’s creation time if LastSyncTime is not available. This can happen if the replication status is bootstrap or unavailable.
+	LastSyncTime *date.Time `json:"lastSyncTime,omitempty"`
+}
+
 // Identity identity for the resource.
 type Identity struct {
 	// PrincipalID - The principal ID of resource identity.