Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,48 +28,50 @@ module Azure::Storage::Mgmt::V2018_02_01
autoload :StorageManagementClient, '2018-02-01/generated/azure_mgmt_storage/storage_management_client.rb'

module Models
autoload :StorageAccountKey, '2018-02-01/generated/azure_mgmt_storage/models/storage_account_key.rb'
autoload :StorageAccountListResult, '2018-02-01/generated/azure_mgmt_storage/models/storage_account_list_result.rb'
autoload :Dimension, '2018-02-01/generated/azure_mgmt_storage/models/dimension.rb'
autoload :StorageAccountListKeysResult, '2018-02-01/generated/azure_mgmt_storage/models/storage_account_list_keys_result.rb'
autoload :ServiceSpecification, '2018-02-01/generated/azure_mgmt_storage/models/service_specification.rb'
autoload :Dimension, '2018-02-01/generated/azure_mgmt_storage/models/dimension.rb'
autoload :StorageAccountRegenerateKeyParameters, '2018-02-01/generated/azure_mgmt_storage/models/storage_account_regenerate_key_parameters.rb'
autoload :OperationListResult, '2018-02-01/generated/azure_mgmt_storage/models/operation_list_result.rb'
autoload :ServiceSpecification, '2018-02-01/generated/azure_mgmt_storage/models/service_specification.rb'
autoload :StorageAccountUpdateParameters, '2018-02-01/generated/azure_mgmt_storage/models/storage_account_update_parameters.rb'
autoload :SKUCapability, '2018-02-01/generated/azure_mgmt_storage/models/skucapability.rb'
autoload :OperationListResult, '2018-02-01/generated/azure_mgmt_storage/models/operation_list_result.rb'
autoload :UsageName, '2018-02-01/generated/azure_mgmt_storage/models/usage_name.rb'
autoload :Sku, '2018-02-01/generated/azure_mgmt_storage/models/sku.rb'
autoload :SKUCapability, '2018-02-01/generated/azure_mgmt_storage/models/skucapability.rb'
autoload :Usage, '2018-02-01/generated/azure_mgmt_storage/models/usage.rb'
autoload :CheckNameAvailabilityResult, '2018-02-01/generated/azure_mgmt_storage/models/check_name_availability_result.rb'
autoload :Sku, '2018-02-01/generated/azure_mgmt_storage/models/sku.rb'
autoload :UsageListResult, '2018-02-01/generated/azure_mgmt_storage/models/usage_list_result.rb'
autoload :EncryptionService, '2018-02-01/generated/azure_mgmt_storage/models/encryption_service.rb'
autoload :CheckNameAvailabilityResult, '2018-02-01/generated/azure_mgmt_storage/models/check_name_availability_result.rb'
autoload :AccountSasParameters, '2018-02-01/generated/azure_mgmt_storage/models/account_sas_parameters.rb'
autoload :KeyVaultProperties, '2018-02-01/generated/azure_mgmt_storage/models/key_vault_properties.rb'
autoload :EncryptionService, '2018-02-01/generated/azure_mgmt_storage/models/encryption_service.rb'
autoload :ListAccountSasResponse, '2018-02-01/generated/azure_mgmt_storage/models/list_account_sas_response.rb'
autoload :VirtualNetworkRule, '2018-02-01/generated/azure_mgmt_storage/models/virtual_network_rule.rb'
autoload :KeyVaultProperties, '2018-02-01/generated/azure_mgmt_storage/models/key_vault_properties.rb'
autoload :ServiceSasParameters, '2018-02-01/generated/azure_mgmt_storage/models/service_sas_parameters.rb'
autoload :NetworkRuleSet, '2018-02-01/generated/azure_mgmt_storage/models/network_rule_set.rb'
autoload :VirtualNetworkRule, '2018-02-01/generated/azure_mgmt_storage/models/virtual_network_rule.rb'
autoload :ListServiceSasResponse, '2018-02-01/generated/azure_mgmt_storage/models/list_service_sas_response.rb'
autoload :NetworkRuleSet, '2018-02-01/generated/azure_mgmt_storage/models/network_rule_set.rb'
autoload :Encryption, '2018-02-01/generated/azure_mgmt_storage/models/encryption.rb'
autoload :StorageAccountCreateParameters, '2018-02-01/generated/azure_mgmt_storage/models/storage_account_create_parameters.rb'
autoload :IPRule, '2018-02-01/generated/azure_mgmt_storage/models/iprule.rb'
autoload :LegalHoldProperties, '2018-02-01/generated/azure_mgmt_storage/models/legal_hold_properties.rb'
autoload :OperationDisplay, '2018-02-01/generated/azure_mgmt_storage/models/operation_display.rb'
autoload :LegalHold, '2018-02-01/generated/azure_mgmt_storage/models/legal_hold.rb'
autoload :StorageAccountKey, '2018-02-01/generated/azure_mgmt_storage/models/storage_account_key.rb'
autoload :Identity, '2018-02-01/generated/azure_mgmt_storage/models/identity.rb'
autoload :Operation, '2018-02-01/generated/azure_mgmt_storage/models/operation.rb'
autoload :Endpoints, '2018-02-01/generated/azure_mgmt_storage/models/endpoints.rb'
autoload :Restriction, '2018-02-01/generated/azure_mgmt_storage/models/restriction.rb'
autoload :CustomDomain, '2018-02-01/generated/azure_mgmt_storage/models/custom_domain.rb'
autoload :ListContainerItems, '2018-02-01/generated/azure_mgmt_storage/models/list_container_items.rb'
autoload :Encryption, '2018-02-01/generated/azure_mgmt_storage/models/encryption.rb'
autoload :Resource, '2018-02-01/generated/azure_mgmt_storage/models/resource.rb'
autoload :MetricSpecification, '2018-02-01/generated/azure_mgmt_storage/models/metric_specification.rb'
autoload :StorageAccountCheckNameAvailabilityParameters, '2018-02-01/generated/azure_mgmt_storage/models/storage_account_check_name_availability_parameters.rb'
autoload :LegalHold, '2018-02-01/generated/azure_mgmt_storage/models/legal_hold.rb'
autoload :LeaseContainerResponse, '2018-02-01/generated/azure_mgmt_storage/models/lease_container_response.rb'
autoload :StorageSkuListResult, '2018-02-01/generated/azure_mgmt_storage/models/storage_sku_list_result.rb'
autoload :Resource, '2018-02-01/generated/azure_mgmt_storage/models/resource.rb'
autoload :EncryptionServices, '2018-02-01/generated/azure_mgmt_storage/models/encryption_services.rb'
autoload :LeaseContainerRequest, '2018-02-01/generated/azure_mgmt_storage/models/lease_container_request.rb'
autoload :OperationDisplay, '2018-02-01/generated/azure_mgmt_storage/models/operation_display.rb'
autoload :UpdateHistoryProperty, '2018-02-01/generated/azure_mgmt_storage/models/update_history_property.rb'
autoload :StorageSkuListResult, '2018-02-01/generated/azure_mgmt_storage/models/storage_sku_list_result.rb'
autoload :Restriction, '2018-02-01/generated/azure_mgmt_storage/models/restriction.rb'
autoload :ImmutabilityPolicyProperties, '2018-02-01/generated/azure_mgmt_storage/models/immutability_policy_properties.rb'
autoload :MetricSpecification, '2018-02-01/generated/azure_mgmt_storage/models/metric_specification.rb'
autoload :Endpoints, '2018-02-01/generated/azure_mgmt_storage/models/endpoints.rb'
autoload :TagProperty, '2018-02-01/generated/azure_mgmt_storage/models/tag_property.rb'
autoload :CustomDomain, '2018-02-01/generated/azure_mgmt_storage/models/custom_domain.rb'
autoload :LegalHoldProperties, '2018-02-01/generated/azure_mgmt_storage/models/legal_hold_properties.rb'
autoload :Operation, '2018-02-01/generated/azure_mgmt_storage/models/operation.rb'
autoload :ListContainerItems, '2018-02-01/generated/azure_mgmt_storage/models/list_container_items.rb'
autoload :StorageAccount, '2018-02-01/generated/azure_mgmt_storage/models/storage_account.rb'
autoload :ProxyResource, '2018-02-01/generated/azure_mgmt_storage/models/proxy_resource.rb'
autoload :AzureEntityResource, '2018-02-01/generated/azure_mgmt_storage/models/azure_entity_resource.rb'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1611,5 +1611,139 @@ def extend_immutability_policy_async(resource_group_name, account_name, containe
promise.execute
end

#
# 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.
#
# @param resource_group_name [String] The name of the resource group within the
# user's subscription. The name is case insensitive.
# @param account_name [String] 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.
# @param container_name [String] 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.
# @param parameters [LeaseContainerRequest] Lease Container request body.
# @param custom_headers [Hash{String => String}] A hash of custom headers that
# will be added to the HTTP request.
#
# @return [LeaseContainerResponse] operation results.
#
def lease(resource_group_name, account_name, container_name, parameters = nil, custom_headers = nil)
response = lease_async(resource_group_name, account_name, container_name, parameters, custom_headers).value!
response.body unless response.nil?
end

#
# 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.
#
# @param resource_group_name [String] The name of the resource group within the
# user's subscription. The name is case insensitive.
# @param account_name [String] 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.
# @param container_name [String] 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.
# @param parameters [LeaseContainerRequest] Lease Container request body.
# @param custom_headers [Hash{String => String}] A hash of custom headers that
# will be added to the HTTP request.
#
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
#
def lease_with_http_info(resource_group_name, account_name, container_name, parameters = nil, custom_headers = nil)
lease_async(resource_group_name, account_name, container_name, parameters, custom_headers).value!
end

#
# 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.
#
# @param resource_group_name [String] The name of the resource group within the
# user's subscription. The name is case insensitive.
# @param account_name [String] 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.
# @param container_name [String] 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.
# @param parameters [LeaseContainerRequest] Lease Container request body.
# @param [Hash{String => String}] A hash of custom headers that will be added
# to the HTTP request.
#
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
#
def lease_async(resource_group_name, account_name, container_name, parameters = nil, custom_headers = nil)
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
fail ArgumentError, 'account_name is nil' if account_name.nil?
fail ArgumentError, 'container_name is nil' if container_name.nil?
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?


request_headers = {}

# Set Headers
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

request_headers['Content-Type'] = 'application/json; charset=utf-8'

# Serialize Request
request_mapper = Azure::Storage::Mgmt::V2018_02_01::Models::LeaseContainerRequest.mapper()
request_content = @client.serialize(request_mapper, parameters)
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'

request_url = @base_url || @client.base_url

options = {
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'containerName' => container_name,'subscriptionId' => @client.subscription_id},
query_params: {'api-version' => @client.api_version},
body: request_content,
headers: request_headers.merge(custom_headers || {}),
base_url: request_url
}
promise = @client.make_request_async(:post, path_template, options)

promise = promise.then do |result|
http_response = result.response
status_code = http_response.status
response_content = http_response.body
unless status_code == 200
error_model = JSON.load(response_content)
fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
end

result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
# Deserialize Response
if status_code == 200
begin
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
result_mapper = Azure::Storage::Mgmt::V2018_02_01::Models::LeaseContainerResponse.mapper()
result.body = @client.deserialize(result_mapper, parsed_response)
rescue Exception => e
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
end
end

result
end

promise.execute
end

end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.

module Azure::Storage::Mgmt::V2018_02_01
module Models
#
# Lease Container request schema.
#
class LeaseContainerRequest

include MsRestAzure

# @return [Enum] Specifies the lease action. Can be one of the available
# actions. Possible values include: 'Acquire', 'Renew', 'Change',
# 'Release', 'Break'
attr_accessor :action

# @return [String] Identifies the lease. Can be specified in any valid
# GUID string format.
attr_accessor :lease_id

# @return [Integer] Optional. For a break action, proposed duration the
# lease should continue before it is broken, in seconds, between 0 and
# 60.
attr_accessor :break_period

# @return [Integer] Required for acquire. Specifies the duration of the
# lease, in seconds, or negative one (-1) for a lease that never expires.
attr_accessor :lease_duration

# @return [String] Optional for acquire, required for change. Proposed
# lease ID, in a GUID string format.
attr_accessor :proposed_lease_id


#
# Mapper for LeaseContainerRequest class as Ruby Hash.
# This will be used for serialization/deserialization.
#
def self.mapper()
{
required: false,
serialized_name: 'LeaseContainerRequest',
type: {
name: 'Composite',
class_name: 'LeaseContainerRequest',
model_properties: {
action: {
required: true,
serialized_name: 'action',
type: {
name: 'String'
}
},
lease_id: {
required: false,
serialized_name: 'leaseId',
type: {
name: 'String'
}
},
break_period: {
required: false,
serialized_name: 'breakPeriod',
type: {
name: 'Number'
}
},
lease_duration: {
required: false,
serialized_name: 'leaseDuration',
type: {
name: 'Number'
}
},
proposed_lease_id: {
required: false,
serialized_name: 'proposedLeaseId',
type: {
name: 'String'
}
}
}
}
}
end
end
end
end
Loading