diff --git a/profiles/latest/storage/mgmt/storage/models.go b/profiles/latest/storage/mgmt/storage/models.go index 0b900172eae1..255161d464a8 100644 --- a/profiles/latest/storage/mgmt/storage/models.go +++ b/profiles/latest/storage/mgmt/storage/models.go @@ -51,6 +51,16 @@ const ( Allow Action = original.Allow ) +type Action1 = original.Action1 + +const ( + Acquire Action1 = original.Acquire + Break Action1 = original.Break + Change Action1 = original.Change + Release Action1 = original.Release + Renew Action1 = original.Renew +) + type Bypass = original.Bypass const ( @@ -297,6 +307,8 @@ type ImmutabilityPolicy = original.ImmutabilityPolicy type ImmutabilityPolicyProperties = original.ImmutabilityPolicyProperties type ImmutabilityPolicyProperty = original.ImmutabilityPolicyProperty type KeyVaultProperties = original.KeyVaultProperties +type LeaseContainerRequest = original.LeaseContainerRequest +type LeaseContainerResponse = original.LeaseContainerResponse type LegalHold = original.LegalHold type LegalHoldProperties = original.LegalHoldProperties type ListAccountSasResponse = original.ListAccountSasResponse @@ -395,6 +407,9 @@ func PossibleAccountExpandValues() []AccountExpand { func PossibleAccountStatusValues() []AccountStatus { return original.PossibleAccountStatusValues() } +func PossibleAction1Values() []Action1 { + return original.PossibleAction1Values() +} func PossibleActionValues() []Action { return original.PossibleActionValues() } diff --git a/profiles/preview/storage/mgmt/storage/models.go b/profiles/preview/storage/mgmt/storage/models.go index af7a30915366..3017aa940306 100644 --- a/profiles/preview/storage/mgmt/storage/models.go +++ b/profiles/preview/storage/mgmt/storage/models.go @@ -51,6 +51,16 @@ const ( Allow Action = original.Allow ) +type Action1 = original.Action1 + +const ( + Acquire Action1 = original.Acquire + Break Action1 = original.Break + Change Action1 = original.Change + Release Action1 = original.Release + Renew Action1 = original.Renew +) + type Bypass = original.Bypass const ( @@ -297,6 +307,8 @@ type ImmutabilityPolicy = original.ImmutabilityPolicy type ImmutabilityPolicyProperties = original.ImmutabilityPolicyProperties type ImmutabilityPolicyProperty = original.ImmutabilityPolicyProperty type KeyVaultProperties = original.KeyVaultProperties +type LeaseContainerRequest = original.LeaseContainerRequest +type LeaseContainerResponse = original.LeaseContainerResponse type LegalHold = original.LegalHold type LegalHoldProperties = original.LegalHoldProperties type ListAccountSasResponse = original.ListAccountSasResponse @@ -395,6 +407,9 @@ func PossibleAccountExpandValues() []AccountExpand { func PossibleAccountStatusValues() []AccountStatus { return original.PossibleAccountStatusValues() } +func PossibleAction1Values() []Action1 { + return original.PossibleAction1Values() +} func PossibleActionValues() []Action { return original.PossibleActionValues() } diff --git a/services/storage/mgmt/2019-04-01/storage/blobcontainers.go b/services/storage/mgmt/2019-04-01/storage/blobcontainers.go index b81563c94c67..85f43ba9626d 100644 --- a/services/storage/mgmt/2019-04-01/storage/blobcontainers.go +++ b/services/storage/mgmt/2019-04-01/storage/blobcontainers.go @@ -904,6 +904,112 @@ func (client BlobContainersClient) GetImmutabilityPolicyResponder(resp *http.Res return } +// Lease the Lease Container operation establishes and manages a lock on a container for delete operations. The lock +// duration can be 15 to 60 seconds, or can be infinite. +// 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. +// containerName - the name of the blob container within the specified storage account. Blob container names +// must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every +// dash (-) character must be immediately preceded and followed by a letter or number. +// parameters - lease Container request body. +func (client BlobContainersClient) Lease(ctx context.Context, resourceGroupName string, accountName string, containerName string, parameters *LeaseContainerRequest) (result LeaseContainerResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BlobContainersClient.Lease") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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: containerName, + Constraints: []validation.Constraint{{Target: "containerName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "containerName", 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.BlobContainersClient", "Lease", err.Error()) + } + + req, err := client.LeasePreparer(ctx, resourceGroupName, accountName, containerName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storage.BlobContainersClient", "Lease", nil, "Failure preparing request") + return + } + + resp, err := client.LeaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storage.BlobContainersClient", "Lease", resp, "Failure sending request") + return + } + + result, err = client.LeaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storage.BlobContainersClient", "Lease", resp, "Failure responding to request") + } + + return +} + +// LeasePreparer prepares the Lease request. +func (client BlobContainersClient) LeasePreparer(ctx context.Context, resourceGroupName string, accountName string, containerName string, parameters *LeaseContainerRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// LeaseSender sends the Lease request. The method will close the +// http.Response Body if it receives an error. +func (client BlobContainersClient) LeaseSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// LeaseResponder handles the response to the Lease request. The method always +// closes the http.Response Body. +func (client BlobContainersClient) LeaseResponder(resp *http.Response) (result LeaseContainerResponse, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // List lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation // token. // Parameters: diff --git a/services/storage/mgmt/2019-04-01/storage/models.go b/services/storage/mgmt/2019-04-01/storage/models.go index 55a8ee25a297..3cfc80ed3f92 100644 --- a/services/storage/mgmt/2019-04-01/storage/models.go +++ b/services/storage/mgmt/2019-04-01/storage/models.go @@ -85,6 +85,27 @@ func PossibleActionValues() []Action { return []Action{Allow} } +// Action1 enumerates the values for action 1. +type Action1 string + +const ( + // Acquire ... + Acquire Action1 = "Acquire" + // Break ... + Break Action1 = "Break" + // Change ... + Change Action1 = "Change" + // Release ... + Release Action1 = "Release" + // Renew ... + Renew Action1 = "Renew" +) + +// PossibleAction1Values returns an array of possible values for the Action1 const type. +func PossibleAction1Values() []Action1 { + return []Action1{Acquire, Break, Change, Release, Renew} +} + // Bypass enumerates the values for bypass. type Bypass string @@ -1568,6 +1589,29 @@ type KeyVaultProperties struct { KeyVaultURI *string `json:"keyvaulturi,omitempty"` } +// LeaseContainerRequest lease Container request schema. +type LeaseContainerRequest struct { + // Action - Specifies the lease action. Can be one of the available actions. Possible values include: 'Acquire', 'Renew', 'Change', 'Release', 'Break' + Action Action1 `json:"action,omitempty"` + // LeaseID - Identifies the lease. Can be specified in any valid GUID string format. + LeaseID *string `json:"leaseId,omitempty"` + // BreakPeriod - Optional. For a break action, proposed duration the lease should continue before it is broken, in seconds, between 0 and 60. + BreakPeriod *int32 `json:"breakPeriod,omitempty"` + // LeaseDuration - Required for acquire. Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. + LeaseDuration *int32 `json:"leaseDuration,omitempty"` + // ProposedLeaseID - Optional for acquire, required for change. Proposed lease ID, in a GUID string format. + ProposedLeaseID *string `json:"proposedLeaseId,omitempty"` +} + +// LeaseContainerResponse lease Container response schema. +type LeaseContainerResponse struct { + autorest.Response `json:"-"` + // LeaseID - Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease. + LeaseID *string `json:"leaseId,omitempty"` + // LeaseTimeSeconds - Approximate time remaining in the lease period, in seconds. + LeaseTimeSeconds *string `json:"leaseTimeSeconds,omitempty"` +} + // LegalHold the LegalHold property of a blob container. type LegalHold struct { autorest.Response `json:"-"` diff --git a/services/storage/mgmt/2019-04-01/storage/storageapi/interfaces.go b/services/storage/mgmt/2019-04-01/storage/storageapi/interfaces.go index c72626c0c31f..e27317a3af14 100644 --- a/services/storage/mgmt/2019-04-01/storage/storageapi/interfaces.go +++ b/services/storage/mgmt/2019-04-01/storage/storageapi/interfaces.go @@ -90,6 +90,7 @@ type BlobContainersClientAPI interface { ExtendImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, parameters *storage.ImmutabilityPolicy) (result storage.ImmutabilityPolicy, err error) Get(ctx context.Context, resourceGroupName string, accountName string, containerName string) (result storage.BlobContainer, err error) GetImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string) (result storage.ImmutabilityPolicy, err error) + Lease(ctx context.Context, resourceGroupName string, accountName string, containerName string, parameters *storage.LeaseContainerRequest) (result storage.LeaseContainerResponse, err error) List(ctx context.Context, resourceGroupName string, accountName string) (result storage.ListContainerItems, err error) LockImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string) (result storage.ImmutabilityPolicy, err error) SetLegalHold(ctx context.Context, resourceGroupName string, accountName string, containerName string, legalHold storage.LegalHold) (result storage.LegalHold, err error)