fog-azure-rm 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +2 -1
- data/fog-azure-rm.gemspec +11 -9
- data/lib/fog/azurerm.rb +1 -0
- data/lib/fog/azurerm/compute.rb +3 -3
- data/lib/fog/azurerm/config.rb +33 -0
- data/lib/fog/azurerm/credentials.rb +1 -1
- data/lib/fog/azurerm/dns.rb +2 -2
- data/lib/fog/azurerm/docs/storage.md +120 -66
- data/lib/fog/azurerm/models/application_gateway/gateway.rb +30 -31
- data/lib/fog/azurerm/models/application_gateway/gateways.rb +4 -4
- data/lib/fog/azurerm/models/compute/availability_sets.rb +4 -4
- data/lib/fog/azurerm/models/compute/server.rb +14 -14
- data/lib/fog/azurerm/models/compute/servers.rb +4 -4
- data/lib/fog/azurerm/models/compute/virtual_machine_extension.rb +3 -5
- data/lib/fog/azurerm/models/compute/virtual_machine_extensions.rb +5 -5
- data/lib/fog/azurerm/models/dns/record_sets.rb +4 -4
- data/lib/fog/azurerm/models/dns/zones.rb +4 -4
- data/lib/fog/azurerm/models/network/express_route_circuit.rb +2 -5
- data/lib/fog/azurerm/models/network/express_route_circuit_authorization.rb +1 -1
- data/lib/fog/azurerm/models/network/express_route_circuit_authorizations.rb +4 -4
- data/lib/fog/azurerm/models/network/express_route_circuit_peering.rb +3 -5
- data/lib/fog/azurerm/models/network/express_route_circuit_peerings.rb +4 -4
- data/lib/fog/azurerm/models/network/express_route_circuits.rb +4 -4
- data/lib/fog/azurerm/models/network/express_route_service_providers.rb +2 -2
- data/lib/fog/azurerm/models/network/load_balancers.rb +5 -5
- data/lib/fog/azurerm/models/network/local_network_gateway.rb +1 -1
- data/lib/fog/azurerm/models/network/local_network_gateways.rb +4 -4
- data/lib/fog/azurerm/models/network/network_interfaces.rb +5 -5
- data/lib/fog/azurerm/models/network/network_security_groups.rb +5 -5
- data/lib/fog/azurerm/models/network/network_security_rule.rb +3 -4
- data/lib/fog/azurerm/models/network/network_security_rules.rb +4 -4
- data/lib/fog/azurerm/models/network/public_ips.rb +4 -4
- data/lib/fog/azurerm/models/network/subnets.rb +4 -4
- data/lib/fog/azurerm/models/network/virtual_network_gateway.rb +6 -7
- data/lib/fog/azurerm/models/network/virtual_network_gateway_connection.rb +5 -5
- data/lib/fog/azurerm/models/network/virtual_network_gateway_connections.rb +4 -4
- data/lib/fog/azurerm/models/network/virtual_network_gateways.rb +4 -4
- data/lib/fog/azurerm/models/network/virtual_networks.rb +4 -4
- data/lib/fog/azurerm/models/resources/azure_resources.rb +2 -2
- data/lib/fog/azurerm/models/resources/deployments.rb +4 -4
- data/lib/fog/azurerm/models/resources/resource_groups.rb +4 -4
- data/lib/fog/azurerm/models/sql/firewall_rule.rb +1 -1
- data/lib/fog/azurerm/models/sql/firewall_rules.rb +4 -4
- data/lib/fog/azurerm/models/sql/sql_database.rb +28 -24
- data/lib/fog/azurerm/models/sql/sql_databases.rb +5 -6
- data/lib/fog/azurerm/models/sql/sql_servers.rb +4 -4
- data/lib/fog/azurerm/models/storage/directories.rb +49 -24
- data/lib/fog/azurerm/models/storage/directory.rb +126 -40
- data/lib/fog/azurerm/models/storage/file.rb +226 -114
- data/lib/fog/azurerm/models/storage/files.rb +168 -13
- data/lib/fog/azurerm/models/storage/recovery_vault.rb +1 -1
- data/lib/fog/azurerm/models/storage/recovery_vaults.rb +4 -4
- data/lib/fog/azurerm/models/storage/storage_account.rb +5 -5
- data/lib/fog/azurerm/models/storage/storage_accounts.rb +4 -4
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_end_point.rb +1 -1
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_end_points.rb +4 -4
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb +4 -4
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profiles.rb +4 -4
- data/lib/fog/azurerm/network.rb +1 -1
- data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +17 -13
- data/lib/fog/azurerm/requests/network/list_virtual_networks.rb +1 -1
- data/lib/fog/azurerm/requests/resources/create_deployment.rb +1 -1
- data/lib/fog/azurerm/requests/resources/create_resource_group.rb +1 -1
- data/lib/fog/azurerm/requests/resources/delete_deployment.rb +1 -1
- data/lib/fog/azurerm/requests/resources/delete_resource_group.rb +1 -1
- data/lib/fog/azurerm/requests/resources/get_deployment.rb +1 -1
- data/lib/fog/azurerm/requests/resources/get_resource_group.rb +1 -1
- data/lib/fog/azurerm/requests/resources/list_deployments.rb +1 -1
- data/lib/fog/azurerm/requests/resources/list_resource_groups.rb +1 -1
- data/lib/fog/azurerm/requests/resources/list_tagged_resources.rb +1 -1
- data/lib/fog/azurerm/requests/resources/tag_resource.rb +1 -1
- data/lib/fog/azurerm/requests/sql/create_or_update_database.rb +3 -3
- data/lib/fog/azurerm/requests/sql/create_or_update_firewall_rule.rb +3 -3
- data/lib/fog/azurerm/requests/sql/create_or_update_sql_server.rb +3 -3
- data/lib/fog/azurerm/requests/sql/delete_database.rb +2 -2
- data/lib/fog/azurerm/requests/sql/delete_firewall_rule.rb +4 -4
- data/lib/fog/azurerm/requests/sql/delete_sql_server.rb +4 -4
- data/lib/fog/azurerm/requests/sql/get_database.rb +3 -3
- data/lib/fog/azurerm/requests/sql/get_firewall_rule.rb +3 -3
- data/lib/fog/azurerm/requests/sql/get_sql_server.rb +3 -3
- data/lib/fog/azurerm/requests/sql/list_databases.rb +3 -3
- data/lib/fog/azurerm/requests/sql/list_firewall_rules.rb +3 -3
- data/lib/fog/azurerm/requests/sql/list_sql_servers.rb +3 -3
- data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +5 -2
- data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +5 -2
- data/lib/fog/azurerm/requests/storage/commit_blob_blocks.rb +30 -0
- data/lib/fog/azurerm/requests/storage/compare_container_blobs.rb +148 -0
- data/lib/fog/azurerm/requests/storage/copy_blob.rb +8 -8
- data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +8 -8
- data/lib/fog/azurerm/requests/storage/create_block_blob.rb +108 -0
- data/lib/fog/azurerm/requests/storage/create_container.rb +12 -10
- data/lib/fog/azurerm/requests/storage/create_disk.rb +45 -19
- data/lib/fog/azurerm/requests/storage/create_or_update_recovery_vault.rb +2 -2
- data/lib/fog/azurerm/requests/storage/create_page_blob.rb +31 -0
- data/lib/fog/azurerm/requests/storage/create_storage_account.rb +2 -2
- data/lib/fog/azurerm/requests/storage/delete_blob.rb +10 -5
- data/lib/fog/azurerm/requests/storage/delete_container.rb +6 -2
- data/lib/fog/azurerm/requests/storage/delete_disk.rb +19 -16
- data/lib/fog/azurerm/requests/storage/get_all_backup_jobs.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_backup_container.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_backup_item.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_backup_job_for_vm.rb +1 -1
- data/lib/fog/azurerm/requests/storage/get_backup_protection_policy.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_blob.rb +163 -0
- data/lib/fog/azurerm/requests/storage/get_blob_http_url.rb +39 -0
- data/lib/fog/azurerm/requests/storage/get_blob_https_url.rb +39 -0
- data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +37 -35
- data/lib/fog/azurerm/requests/storage/get_blob_url.rb +28 -0
- data/lib/fog/azurerm/requests/storage/get_container_acl.rb +30 -0
- data/lib/fog/azurerm/requests/storage/get_container_properties.rb +16 -12
- data/lib/fog/azurerm/requests/storage/get_container_url.rb +34 -0
- data/lib/fog/azurerm/requests/storage/get_recovery_vault.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_storage_access_keys.rb +4 -3
- data/lib/fog/azurerm/requests/storage/get_storage_account.rb +2 -2
- data/lib/fog/azurerm/requests/storage/list_blobs.rb +110 -24
- data/lib/fog/azurerm/requests/storage/list_containers.rb +46 -23
- data/lib/fog/azurerm/requests/storage/list_recovery_vaults.rb +2 -2
- data/lib/fog/azurerm/requests/storage/list_storage_account_for_rg.rb +2 -2
- data/lib/fog/azurerm/requests/storage/list_storage_accounts.rb +2 -2
- data/lib/fog/azurerm/requests/storage/multipart_save_block_blob.rb +110 -0
- data/lib/fog/azurerm/requests/storage/put_blob_block.rb +30 -0
- data/lib/fog/azurerm/requests/storage/{set_blob_metadata.rb → put_blob_metadata.rb} +7 -3
- data/lib/fog/azurerm/requests/storage/put_blob_pages.rb +30 -0
- data/lib/fog/azurerm/requests/storage/put_blob_properties.rb +31 -0
- data/lib/fog/azurerm/requests/storage/put_container_acl.rb +31 -0
- data/lib/fog/azurerm/requests/storage/{set_container_metadata.rb → put_container_metadata.rb} +7 -3
- data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +4 -1
- data/lib/fog/azurerm/requests/storage/release_container_lease.rb +4 -1
- data/lib/fog/azurerm/requests/storage/save_page_blob.rb +111 -0
- data/lib/fog/azurerm/requests/storage/start_backup.rb +1 -1
- data/lib/fog/azurerm/requests/storage/wait_blob_copy_operation_to_finish.rb +56 -0
- data/lib/fog/azurerm/resources.rb +2 -2
- data/lib/fog/azurerm/storage.rb +33 -19
- data/lib/fog/azurerm/traffic_manager.rb +1 -1
- data/lib/fog/azurerm/utilities/general.rb +70 -3
- data/lib/fog/azurerm/version.rb +1 -1
- data/rake-script.sh +5 -2
- data/test/api_stub/models/application_gateway/gateway.rb +1 -1
- data/test/api_stub/models/compute/server.rb +1 -1
- data/test/api_stub/models/dns/record_set.rb +2 -2
- data/test/api_stub/models/dns/zone.rb +1 -1
- data/test/api_stub/models/network/express_route_circuit.rb +1 -1
- data/test/api_stub/models/network/express_route_circuit_authorization.rb +1 -1
- data/test/api_stub/models/network/express_route_circuit_peering.rb +1 -1
- data/test/api_stub/models/network/express_route_service_provider.rb +1 -1
- data/test/api_stub/models/network/load_balancer.rb +1 -1
- data/test/api_stub/models/network/network_interface.rb +1 -1
- data/test/api_stub/models/network/network_security_group.rb +1 -1
- data/test/api_stub/models/network/network_security_rule.rb +1 -1
- data/test/api_stub/models/network/public_ip.rb +1 -1
- data/test/api_stub/models/network/subnet.rb +1 -1
- data/test/api_stub/models/network/virtual_network.rb +1 -1
- data/test/api_stub/models/network/virtual_network_gateway.rb +1 -1
- data/test/api_stub/models/network/virtual_network_gateway_connection.rb +1 -1
- data/test/api_stub/models/resources/resource.rb +2 -2
- data/test/api_stub/models/resources/resource_group.rb +1 -1
- data/test/api_stub/models/storage/directory.rb +148 -62
- data/test/api_stub/models/storage/file.rb +122 -119
- data/test/api_stub/models/traffic_manager/traffic_manager_end_point.rb +1 -1
- data/test/api_stub/models/traffic_manager/traffic_manager_profile.rb +1 -1
- data/test/api_stub/requests/application_gateway/gateway.rb +2 -2
- data/test/api_stub/requests/compute/availability_set.rb +3 -3
- data/test/api_stub/requests/compute/virtual_machine.rb +9 -9
- data/test/api_stub/requests/dns/record_set.rb +3 -3
- data/test/api_stub/requests/dns/zone.rb +18 -18
- data/test/api_stub/requests/network/express_route_circuit.rb +2 -2
- data/test/api_stub/requests/network/express_route_circuit_authorization.rb +1 -1
- data/test/api_stub/requests/network/express_route_circuit_peering.rb +2 -2
- data/test/api_stub/requests/network/express_route_service_provider.rb +1 -1
- data/test/api_stub/requests/network/load_balancer.rb +2 -2
- data/test/api_stub/requests/network/network_interface.rb +4 -4
- data/test/api_stub/requests/network/network_security_group.rb +3 -3
- data/test/api_stub/requests/network/network_security_rule.rb +2 -2
- data/test/api_stub/requests/network/public_ip.rb +2 -2
- data/test/api_stub/requests/network/subnet.rb +2 -2
- data/test/api_stub/requests/network/virtual_network.rb +2 -2
- data/test/api_stub/requests/network/virtual_network_gateway.rb +2 -2
- data/test/api_stub/requests/network/virtual_network_gateway_connection.rb +3 -3
- data/test/api_stub/requests/resources/resource.rb +2 -2
- data/test/api_stub/requests/resources/resource_group.rb +2 -2
- data/test/api_stub/requests/storage/directory.rb +59 -65
- data/test/api_stub/requests/storage/file.rb +183 -113
- data/test/api_stub/requests/storage/storageaccount.rb +1 -1
- data/test/api_stub/requests/traffic_manager/traffic_manager_endpoint.rb +1 -1
- data/test/api_stub/requests/traffic_manager/traffic_manager_profile.rb +2 -2
- data/test/integration/Virtual_network_gateway_connection.rb +189 -182
- data/test/integration/application_gateway.rb +208 -183
- data/test/integration/availability_set.rb +44 -27
- data/test/integration/blob.rb +293 -169
- data/test/integration/container.rb +93 -42
- data/test/integration/data_disk.rb +57 -46
- data/test/integration/deployment.rb +40 -32
- data/test/integration/express_route_circuit.rb +86 -82
- data/test/integration/external_load_balancer.rb +108 -100
- data/test/integration/internal_load_balancer.rb +115 -106
- data/test/integration/local_network_gateway.rb +46 -39
- data/test/integration/network_interface.rb +119 -107
- data/test/integration/network_security_group.rb +86 -74
- data/test/integration/network_security_rule.rb +65 -57
- data/test/integration/public_ip.rb +50 -42
- data/test/integration/record_set.rb +90 -78
- data/test/integration/resource_group.rb +26 -14
- data/test/integration/resource_tag.rb +56 -45
- data/test/integration/server.rb +152 -135
- data/test/integration/server_custom_image.rb +85 -76
- data/test/integration/sql_server.rb +130 -117
- data/test/integration/storage_account.rb +82 -70
- data/test/integration/subnet.rb +87 -74
- data/test/integration/traffic_manager.rb +86 -74
- data/test/integration/virtual_machine_extension.rb +115 -106
- data/test/integration/virtual_network.rb +121 -100
- data/test/integration/virtual_network_gateway.rb +86 -79
- data/test/integration/virtual_network_gateway_connection_to_express_route.rb +94 -87
- data/test/integration/zone.rb +36 -28
- data/test/models/storage/test_directories.rb +26 -71
- data/test/models/storage/test_directory.rb +111 -58
- data/test/models/storage/test_file.rb +179 -143
- data/test/models/storage/test_files.rb +197 -30
- data/test/models/storage/test_storage_account.rb +1 -1
- data/test/requests/compute/test_attach_data_disk_to_vm.rb +15 -17
- data/test/requests/storage/test_acquire_blob_lease.rb +23 -4
- data/test/requests/storage/test_acquire_container_lease.rb +24 -5
- data/test/requests/storage/test_commit_blob_blocks.rb +34 -0
- data/test/requests/storage/test_compare_container_blobs.rb +36 -0
- data/test/requests/storage/test_copy_blob.rb +22 -3
- data/test/requests/storage/test_copy_blob_from_uri.rb +23 -4
- data/test/requests/storage/test_create_block_blob.rb +80 -0
- data/test/requests/storage/test_create_container.rb +18 -13
- data/test/requests/storage/test_create_disk.rb +57 -4
- data/test/requests/storage/test_create_page_blob.rb +34 -0
- data/test/requests/storage/test_delete_blob.rb +25 -5
- data/test/requests/storage/test_delete_container.rb +21 -9
- data/test/requests/storage/test_delete_disk.rb +14 -7
- data/test/requests/storage/test_get_blob.rb +141 -0
- data/test/requests/storage/test_get_blob_http_url.rb +30 -0
- data/test/requests/storage/test_get_blob_https_url.rb +30 -0
- data/test/requests/storage/test_get_blob_properties.rb +29 -7
- data/test/requests/storage/test_get_blob_url.rb +33 -0
- data/test/requests/storage/test_get_container_acl.rb +37 -0
- data/test/requests/storage/test_get_container_properties.rb +25 -11
- data/test/requests/storage/test_get_container_url.rb +33 -0
- data/test/requests/storage/test_list_blobs.rb +77 -0
- data/test/requests/storage/test_list_containers.rb +38 -7
- data/test/requests/storage/test_multipart_save_block_blob.rb +105 -0
- data/test/requests/storage/test_put_blob_block.rb +34 -0
- data/test/requests/storage/test_put_blob_metadata.rb +36 -0
- data/test/requests/storage/test_put_blob_pages.rb +34 -0
- data/test/requests/storage/test_put_blob_properties.rb +39 -0
- data/test/requests/storage/test_put_container_acl.rb +34 -0
- data/test/requests/storage/test_put_container_metadata.rb +36 -0
- data/test/requests/storage/test_release_blob_lease.rb +20 -2
- data/test/requests/storage/test_release_container_lease.rb +21 -3
- data/test/requests/storage/test_save_page_blob.rb +115 -0
- data/test/requests/storage/test_wait_blob_copy_operation_to_finish.rb +148 -0
- data/test/test_helper.rb +34 -21
- metadata +92 -46
- data/lib/fog/azurerm/requests/storage/check_blob_exist.rb +0 -25
- data/lib/fog/azurerm/requests/storage/compare_blob.rb +0 -73
- data/lib/fog/azurerm/requests/storage/download_blob_to_file.rb +0 -56
- data/lib/fog/azurerm/requests/storage/get_blob_metadata.rb +0 -59
- data/lib/fog/azurerm/requests/storage/get_container_access_control_list.rb +0 -30
- data/lib/fog/azurerm/requests/storage/get_container_metadata.rb +0 -32
- data/lib/fog/azurerm/requests/storage/set_blob_properties.rb +0 -26
- data/lib/fog/azurerm/requests/storage/upload_block_blob_from_file.rb +0 -60
- data/test/requests/storage/test_check_blob_exist.rb +0 -17
- data/test/requests/storage/test_compare_blob.rb +0 -17
- data/test/requests/storage/test_download_blob_to_file.rb +0 -25
- data/test/requests/storage/test_get_blob_metadata.rb +0 -18
- data/test/requests/storage/test_get_container_access_control_list.rb +0 -31
- data/test/requests/storage/test_get_container_metadata.rb +0 -18
- data/test/requests/storage/test_list_blobs_in_container.rb +0 -23
- data/test/requests/storage/test_set_blob_metadata.rb +0 -17
- data/test/requests/storage/test_set_blob_properties.rb +0 -16
- data/test/requests/storage/test_set_container_metadata.rb +0 -17
- data/test/requests/storage/test_upload_block_blob_from_file.rb +0 -23
@@ -4,146 +4,258 @@ module Fog
|
|
4
4
|
# This class is giving implementation of create/save and
|
5
5
|
# delete/destroy for Blob.
|
6
6
|
class File < Fog::Model
|
7
|
-
identity
|
8
|
-
|
9
|
-
|
10
|
-
attribute :committed_block_count
|
11
|
-
attribute :content_length
|
12
|
-
attribute :content_type
|
13
|
-
attribute :content_md5
|
14
|
-
attribute :content_encoding
|
15
|
-
attribute :content_language
|
16
|
-
attribute :content_disposition
|
17
|
-
attribute :copy_completion_time
|
18
|
-
attribute :copy_status
|
19
|
-
attribute :copy_status_description
|
20
|
-
attribute :copy_id
|
21
|
-
attribute :copy_progress
|
22
|
-
attribute :copy_source
|
7
|
+
identity :key, aliases: %w(Name name Key)
|
8
|
+
|
9
|
+
attr_writer :body
|
23
10
|
attribute :directory
|
24
|
-
attribute :
|
25
|
-
attribute :
|
26
|
-
attribute :
|
27
|
-
attribute :
|
28
|
-
attribute :
|
29
|
-
attribute :
|
11
|
+
attribute :accept_ranges, aliases: %w(Accept-Ranges AcceptRanges)
|
12
|
+
attribute :content_length, aliases: %w(Content-Length Size), type: :integer
|
13
|
+
attribute :content_type, aliases: %w(Content-Type ContentType)
|
14
|
+
attribute :content_md5, aliases: %w(Content-MD5 ContentMD5)
|
15
|
+
attribute :content_encoding, aliases: %w(Content-Encoding ContentEncoding)
|
16
|
+
attribute :content_language, aliases: %w(Content-Language ContentLanguage)
|
17
|
+
attribute :cache_control, aliases: %w(Cache-Control CacheControl)
|
18
|
+
attribute :content_disposition, aliases: %w(Content-Disposition ContentDisposition)
|
19
|
+
attribute :copy_completion_time, aliases: %w(Copy-Completion-Time CopyCompletionTime)
|
20
|
+
attribute :copy_status, aliases: %w(Copy-Status CopyStatus)
|
21
|
+
attribute :copy_status_description, aliases: %w(Copy-Status-Description CopyStatusDescription)
|
22
|
+
attribute :copy_id, aliases: %w(Copy-Id CopyId)
|
23
|
+
attribute :copy_progress, aliases: %w(Copy-Progress CopyProgress)
|
24
|
+
attribute :copy_source, aliases: %w(Copy-Source CopySource)
|
25
|
+
attribute :etag, aliases: %w(Etag ETag)
|
26
|
+
attribute :last_modified, aliases: %w(Last-Modified LastModified), type: 'time'
|
27
|
+
attribute :lease_duration, aliases: %w(Lease-Duration LeaseDuration)
|
28
|
+
attribute :lease_state, aliases: %w(Lease-State LeaseState)
|
29
|
+
attribute :lease_status, aliases: %w(Lease-Status LeaseStatus)
|
30
|
+
attribute :sequence_number, aliases: %w(Sequence-Number SequenceNumber)
|
31
|
+
attribute :blob_type, aliases: %w(Blob-Type BlobType)
|
30
32
|
attribute :metadata
|
31
|
-
attribute :sequence_number
|
32
|
-
attribute :blob_type
|
33
33
|
|
34
|
+
# Save the file to the directory in Azure storage.
|
35
|
+
# TODO: Support snapshots.
|
36
|
+
#
|
37
|
+
# required attributes: body(Only if update_body is true), directory, key
|
38
|
+
#
|
39
|
+
# @param identity [String] Name of directory
|
40
|
+
# @param options [Hash]
|
41
|
+
# @option options [Boolean] update_body Sets whether to upload the body of the file. Default is true.
|
42
|
+
# Will update metadata and properties when update_body is set to false.
|
43
|
+
# @option options [Integer] worker_thread_num Sets how many threads will be used to upload the body. Default is 8.
|
44
|
+
# @option options [String] blob_type or
|
45
|
+
# Blob-Type Sets blob type for the file. Options: 'BlockBlob' or 'PageBlob'. Default is 'BlockBlob'.
|
46
|
+
# @option options [String] content_type or
|
47
|
+
# Content-Type Sets content type for the file. For example, 'text/plain'.
|
48
|
+
# @option options [String] content_md5 or
|
49
|
+
# Content-MD5 Sets content MD5 hash for the file. Only for store.
|
50
|
+
# When a block file whose size <= 32 MB, Azure will verify the integrity of the blob during transport.
|
51
|
+
# Please reference this issue: https://github.com/Azure/azure-storage-ruby/issues/64
|
52
|
+
# @option options [String] content_encoding or
|
53
|
+
# Content-Encoding Sets content encoding for the file. For example, 'x-gzip'.
|
54
|
+
# @option options [String] content_language or
|
55
|
+
# Content-Language Sets the natural languages used by the file.
|
56
|
+
# @option options [String] cache_control or
|
57
|
+
# Cache-Control Sets content encoding for the file. For example, 'No-cache'.
|
58
|
+
# @option options [String] content_disposition or
|
59
|
+
# Content-Disposition Sets content disposition for the file. For exampple, 'attachment; filename=testing.txt'.
|
60
|
+
# @option options [Hash] metadata Sets custom metadata values to store with the file.
|
61
|
+
#
|
62
|
+
# @return [Boolean]
|
63
|
+
#
|
34
64
|
def save(options = {})
|
35
|
-
|
36
|
-
|
37
|
-
|
65
|
+
update_body = options.delete(:update_body)
|
66
|
+
update_body = true if update_body.nil?
|
67
|
+
requires :directory, :key
|
68
|
+
raise ArgumentError.new('body is required when update_body is true') if update_body && attributes[:body].nil?
|
69
|
+
|
70
|
+
remap_attributes(
|
71
|
+
options,
|
72
|
+
'Blob-Type' => :blob_type,
|
73
|
+
'Content-Type' => :content_type,
|
74
|
+
'Content-MD5' => :content_md5,
|
75
|
+
'Content-Encoding' => :content_encoding,
|
76
|
+
'Content-Language' => :content_language,
|
77
|
+
'Cache-Control' => :cache_control,
|
78
|
+
'Content-Disposition' => :content_disposition
|
79
|
+
)
|
80
|
+
options = {
|
81
|
+
blob_type: blob_type,
|
82
|
+
content_type: content_type,
|
83
|
+
content_md5: content_md5,
|
84
|
+
content_encoding: content_encoding,
|
85
|
+
content_language: content_language,
|
86
|
+
cache_control: cache_control,
|
87
|
+
content_disposition: content_disposition,
|
88
|
+
metadata: metadata
|
89
|
+
}.merge!(options)
|
90
|
+
options = options.reject { |_key, value| value.nil? || value.to_s.empty? }
|
91
|
+
|
92
|
+
if update_body
|
93
|
+
blob = save_blob(options)
|
94
|
+
|
95
|
+
data = parse_storage_object(blob)
|
96
|
+
merge_attributes(data)
|
97
|
+
attributes[:content_length] = Fog::Storage.get_body_size(body)
|
98
|
+
attributes[:content_type] ||= Fog::Storage.get_content_type(body)
|
99
|
+
else
|
100
|
+
service.put_blob_metadata(directory.key, key, options[:metadata]) if options[:metadata]
|
101
|
+
options.delete(:metadata)
|
102
|
+
service.put_blob_properties(directory.key, key, options)
|
103
|
+
|
104
|
+
blob = service.get_blob_properties(directory.key, key)
|
105
|
+
data = parse_storage_object(blob)
|
106
|
+
merge_attributes(data)
|
107
|
+
end
|
108
|
+
|
109
|
+
true
|
38
110
|
end
|
39
111
|
|
40
|
-
|
112
|
+
# Get file's body if exists, else ''.
|
113
|
+
#
|
114
|
+
# @return [File || String]
|
115
|
+
#
|
116
|
+
def body
|
117
|
+
return attributes[:body] if attributes[:body]
|
118
|
+
return '' unless last_modified
|
41
119
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
120
|
+
file = collection.get(identity)
|
121
|
+
if file.nil?
|
122
|
+
attributes[:body] = ''
|
123
|
+
return ''
|
124
|
+
end
|
125
|
+
|
126
|
+
attributes[:body] = file.body
|
46
127
|
end
|
47
128
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
129
|
+
# Set body attribute.
|
130
|
+
#
|
131
|
+
# @param new_body [File || String]
|
132
|
+
#
|
133
|
+
# @return [File || String]
|
134
|
+
#
|
135
|
+
def body=(new_body)
|
136
|
+
attributes[:body] = new_body
|
53
137
|
end
|
54
138
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
139
|
+
# Copy object from one container to other container.
|
140
|
+
#
|
141
|
+
# required attributes: directory, key
|
142
|
+
#
|
143
|
+
# @param target_directory_key [String]
|
144
|
+
# @param target_file_key [String]
|
145
|
+
# @param options [Hash] options for copy_object method
|
146
|
+
# @option options [Integer] timeout Sets to raise a TimeoutError if the copy does not finish in timeout seconds.
|
147
|
+
#
|
148
|
+
# @return [Fog::Storage::AzureRM::File] New File.
|
149
|
+
#
|
150
|
+
def copy(target_directory_key, target_file_key, options = {})
|
151
|
+
requires :directory, :key
|
152
|
+
|
153
|
+
timeout = options.delete(:timeout)
|
154
|
+
copy_id, copy_status = service.copy_blob(target_directory_key, target_file_key, directory.key, key, options)
|
155
|
+
service.wait_blob_copy_operation_to_finish(target_directory_key, target_file_key, copy_id, copy_status, timeout)
|
156
|
+
|
157
|
+
target_directory = service.directories.new(key: target_directory_key)
|
158
|
+
target_directory.files.head(target_file_key)
|
59
159
|
end
|
60
160
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
161
|
+
# Copy object from a uri.
|
162
|
+
#
|
163
|
+
# required attributes: directory, key
|
164
|
+
#
|
165
|
+
# @param source_uri [String]
|
166
|
+
# @param options [Hash] options for copy_object method
|
167
|
+
# @option options [Integer] timeout Sets to raise a TimeoutError if the copy does not finish in timeout seconds.
|
168
|
+
#
|
169
|
+
# @return [Boolean]
|
170
|
+
#
|
171
|
+
def copy_from_uri(source_uri, options = {})
|
172
|
+
requires :directory, :key
|
173
|
+
|
174
|
+
timeout = options.delete(:timeout)
|
175
|
+
copy_id, copy_status = service.copy_blob_from_uri(directory.key, key, source_uri, options)
|
176
|
+
service.wait_blob_copy_operation_to_finish(directory.key, key, copy_id, copy_status, timeout)
|
177
|
+
|
178
|
+
blob = service.get_blob_properties(directory.key, key)
|
179
|
+
data = parse_storage_object(blob)
|
180
|
+
merge_attributes(data)
|
181
|
+
|
182
|
+
true
|
66
183
|
end
|
67
184
|
|
68
|
-
|
185
|
+
# Destroy file.
|
186
|
+
#
|
187
|
+
# required attributes: directory, key
|
188
|
+
#
|
189
|
+
# @param options [Hash]
|
190
|
+
# @option options versionId []
|
191
|
+
#
|
192
|
+
# @return [Boolean] true if successful
|
193
|
+
#
|
194
|
+
def destroy(options = {})
|
69
195
|
requires :key
|
70
196
|
requires :directory
|
71
|
-
|
197
|
+
attributes[:body] = nil
|
198
|
+
service.delete_blob(directory.key, key, options)
|
199
|
+
|
200
|
+
true
|
72
201
|
end
|
73
202
|
|
74
|
-
|
75
|
-
|
203
|
+
# Get whether the file can be accessed by anonymous.
|
204
|
+
#
|
205
|
+
# @return [Boolean]
|
206
|
+
#
|
207
|
+
def public?
|
76
208
|
requires :directory
|
77
|
-
|
78
|
-
|
209
|
+
|
210
|
+
# TBD: The blob can be accessed if read permision is set in one access policy of the container.
|
211
|
+
directory.acl == 'container' || directory.acl == 'blob'
|
79
212
|
end
|
80
213
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
214
|
+
# Get publicly accessible url.
|
215
|
+
#
|
216
|
+
# required attributes: directory, key
|
217
|
+
#
|
218
|
+
# @param options [Hash]
|
219
|
+
# @option options [String] scheme Sets which URL to get, http or https. Options: https or http. Default is https.
|
220
|
+
#
|
221
|
+
# @return [String] A public url.
|
222
|
+
#
|
223
|
+
def public_url(options = {})
|
224
|
+
requires :directory, :key
|
225
|
+
options[:scheme] == 'https' if options[:scheme].nil?
|
226
|
+
@service.get_blob_url(directory.key, key, options) if public?
|
87
227
|
end
|
88
228
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
hash['content_encoding'] = blob['properties']['content_encoding']
|
103
|
-
hash['content_language'] = blob['properties']['content_language']
|
104
|
-
hash['content_disposition'] = blob['properties']['content_disposition']
|
105
|
-
hash['content_md5'] = blob['properties']['content_md5']
|
106
|
-
hash['cache_control'] = blob['properties']['cache_control']
|
107
|
-
hash['sequence_number'] = blob['properties']['sequence_number']
|
108
|
-
hash['blob_type'] = blob['properties']['blob_type']
|
109
|
-
hash['copy_id'] = blob['properties']['copy_id']
|
110
|
-
hash['copy_status'] = blob['properties']['copy_status']
|
111
|
-
hash['copy_source'] = blob['properties']['copy_source']
|
112
|
-
hash['copy_progress'] = blob['properties']['copy_progress']
|
113
|
-
hash['copy_completion_time'] = blob['properties']['copy_completion_time']
|
114
|
-
hash['copy_status_description'] = blob['properties']['copy_status_description']
|
115
|
-
hash['accept_ranges'] = blob['properties']['accept_ranges']
|
116
|
-
hash
|
229
|
+
# Get a url for file.
|
230
|
+
#
|
231
|
+
# required attributes: key
|
232
|
+
#
|
233
|
+
# @param expires [Time] The time at which the shared access signature becomes invalid, in a UTC format.
|
234
|
+
# @param options [Hash]
|
235
|
+
# @option options [String] scheme Sets which URL to get, http or https. Options: https or http. Default is https.
|
236
|
+
#
|
237
|
+
# @return [String] A public url which will expire after the specified time.
|
238
|
+
#
|
239
|
+
def url(expires, options = {})
|
240
|
+
requires :key
|
241
|
+
collection.get_url(key, expires, options)
|
117
242
|
end
|
118
243
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
hash['content_disposition'] = blob.properties[:content_disposition]
|
135
|
-
hash['content_md5'] = blob.properties[:content_md5]
|
136
|
-
hash['cache_control'] = blob.properties[:cache_control]
|
137
|
-
hash['sequence_number'] = blob.properties[:sequence_number]
|
138
|
-
hash['blob_type'] = blob.properties[:blob_type]
|
139
|
-
hash['copy_id'] = blob.properties[:copy_id]
|
140
|
-
hash['copy_status'] = blob.properties[:copy_status]
|
141
|
-
hash['copy_source'] = blob.properties[:copy_source]
|
142
|
-
hash['copy_progress'] = blob.properties[:copy_progress]
|
143
|
-
hash['copy_completion_time'] = blob.properties[:copy_completion_time]
|
144
|
-
hash['copy_status_description'] = blob.properties[:copy_status_description]
|
145
|
-
hash['accept_ranges'] = blob.properties[:accept_ranges]
|
146
|
-
hash
|
244
|
+
private
|
245
|
+
|
246
|
+
# Upload blob
|
247
|
+
def save_blob(options)
|
248
|
+
if options[:blob_type].nil? || options[:blob_type] == 'BlockBlob'
|
249
|
+
if Fog::Storage.get_body_size(body) <= SINGLE_BLOB_PUT_THRESHOLD
|
250
|
+
service.create_block_blob(directory.key, key, body, options)
|
251
|
+
else
|
252
|
+
service.multipart_save_block_blob(directory.key, key, body, options)
|
253
|
+
service.get_blob_properties(directory.key, key)
|
254
|
+
end
|
255
|
+
else
|
256
|
+
service.save_page_blob(directory.key, key, body, options)
|
257
|
+
service.get_blob_properties(directory.key, key)
|
258
|
+
end
|
147
259
|
end
|
148
260
|
end
|
149
261
|
end
|
@@ -3,24 +3,179 @@ module Fog
|
|
3
3
|
class AzureRM
|
4
4
|
# This class is giving implementation of listing blobs.
|
5
5
|
class Files < Fog::Collection
|
6
|
-
model File
|
7
6
|
attribute :directory
|
7
|
+
attribute :delimiter, aliases: 'Delimiter'
|
8
|
+
attribute :marker, aliases: 'Marker'
|
9
|
+
attribute :max_results, aliases: %w(max-results MaxResults max_keys MaxKeys max-keys)
|
10
|
+
attribute :next_marker, aliases: %w(NextMarker next-marker)
|
11
|
+
attribute :prefix, aliases: 'Prefix'
|
8
12
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
model Fog::Storage::AzureRM::File
|
14
|
+
|
15
|
+
# List all files(blobs) under the directory.
|
16
|
+
#
|
17
|
+
# required attributes: directory
|
18
|
+
#
|
19
|
+
# @param options [Hash]
|
20
|
+
# @option options [String] max_keys or
|
21
|
+
# max_results Sets the maximum number of files to return.
|
22
|
+
# @option options [String] delimiter Sets to cause that the operation returns a BlobPrefix element in the response body that acts
|
23
|
+
# as a placeholder for all files whose names begin with the same substring up to the appearance
|
24
|
+
# of the delimiter character. The delimiter may be a single character or a string.
|
25
|
+
# @option options [String] marker Sets the identifier that specifies the portion of the list to be returned.
|
26
|
+
# @option options [String] prefix Sets filters the results to return only files whose name begins with the specified prefix.
|
27
|
+
#
|
28
|
+
# @return [Fog::Storage::AzureRM::Files] Return nil if the directory does not exist.
|
29
|
+
#
|
30
|
+
def all(options = {})
|
31
|
+
requires :directory
|
32
|
+
|
33
|
+
options = {
|
34
|
+
max_results: max_results,
|
35
|
+
delimiter: delimiter,
|
36
|
+
marker: marker,
|
37
|
+
prefix: prefix
|
38
|
+
}.merge!(options)
|
39
|
+
options = options.reject { |_key, value| value.nil? || value.to_s.empty? }
|
40
|
+
merge_attributes(options)
|
41
|
+
parent = directory.collection.get(
|
42
|
+
directory.key,
|
43
|
+
options
|
44
|
+
)
|
45
|
+
return nil unless parent
|
46
|
+
|
47
|
+
merge_attributes(parent.files.attributes)
|
48
|
+
load(parent.files.map(&:attributes))
|
49
|
+
end
|
50
|
+
|
51
|
+
# Enumerate every file under the directory if block_given?
|
52
|
+
#
|
53
|
+
# @return [Fog::Storage::AzureRM::Files]
|
54
|
+
#
|
55
|
+
alias each_file_this_page each
|
56
|
+
def each
|
57
|
+
if block_given?
|
58
|
+
subset = dup.all
|
59
|
+
|
60
|
+
subset.each_file_this_page { |f| yield f }
|
61
|
+
while subset.next_marker
|
62
|
+
subset = subset.all(marker: subset.next_marker)
|
63
|
+
subset.each_file_this_page { |f| yield f }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
self
|
68
|
+
end
|
69
|
+
|
70
|
+
# Get the file(blob) with full content as :body with the given name.
|
71
|
+
#
|
72
|
+
# required attributes: directory
|
73
|
+
#
|
74
|
+
# @param key [String] Name of file
|
75
|
+
# @param options [Hash]
|
76
|
+
# @option options [String] block_size Sets buffer size when block_given? is true. Default is 32 MB
|
77
|
+
#
|
78
|
+
# @return [Fog::Storage::AzureRM::File] A file. Return nil if the file does not exist.
|
79
|
+
#
|
80
|
+
def get(key, options = {}, &block)
|
81
|
+
requires :directory
|
82
|
+
|
83
|
+
blob, content = service.get_blob(directory.key, key, options, &block)
|
84
|
+
data = parse_storage_object(blob)
|
85
|
+
file_data = data.merge(
|
86
|
+
body: content,
|
87
|
+
key: key
|
88
|
+
)
|
89
|
+
new(file_data)
|
90
|
+
rescue => error
|
91
|
+
return nil if error.message == 'NotFound'
|
92
|
+
raise error
|
93
|
+
end
|
94
|
+
|
95
|
+
# Get the URL of the file(blob) with the given name.
|
96
|
+
#
|
97
|
+
# required attributes: directory
|
98
|
+
#
|
99
|
+
# @param key [String] Name of file
|
100
|
+
# @param expires [Time] The time at which the shared access signature becomes invalid, in a UTC format.
|
101
|
+
# @param options [Hash]
|
102
|
+
# @option options [String] scheme Sets which URL to get, http or https. Options: https or http. Default is https.
|
103
|
+
#
|
104
|
+
# @return [String] A URL.
|
105
|
+
#
|
106
|
+
def get_url(key, expires, options = {})
|
107
|
+
requires :directory
|
108
|
+
|
109
|
+
if options[:scheme] == 'http'
|
110
|
+
get_http_url(key, expires, options)
|
111
|
+
else
|
112
|
+
get_https_url(key, expires, options)
|
15
113
|
end
|
16
|
-
load files
|
17
114
|
end
|
18
115
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
116
|
+
# Get the http URL of the file(blob) with the given name.
|
117
|
+
#
|
118
|
+
# required attributes: directory
|
119
|
+
#
|
120
|
+
# @param key [String] Name of file
|
121
|
+
# @param expires [Time] The time at which the shared access signature becomes invalid, in a UTC format.
|
122
|
+
# @param options [Hash] Unused. To keep same interface as other providers.
|
123
|
+
#
|
124
|
+
# @return [String] A http URL.
|
125
|
+
#
|
126
|
+
def get_http_url(key, expires, _options = {})
|
127
|
+
requires :directory
|
128
|
+
|
129
|
+
service.get_blob_http_url(directory.key, key, expires)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Get the https URL of the file(blob) with the given name.
|
133
|
+
#
|
134
|
+
# required attributes: directory
|
135
|
+
#
|
136
|
+
# @param key [String] Name of file
|
137
|
+
# @param expires [Time] The time at which the shared access signature becomes invalid, in a UTC format.
|
138
|
+
# @param options [Hash] Unused. To keep same interface as other providers.
|
139
|
+
#
|
140
|
+
# @return [String] A https URL.
|
141
|
+
#
|
142
|
+
def get_https_url(key, expires, _options = {})
|
143
|
+
requires :directory
|
144
|
+
|
145
|
+
service.get_blob_https_url(directory.key, key, expires)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Get the file(blob) without content with the given name.
|
149
|
+
#
|
150
|
+
# required attributes: directory
|
151
|
+
#
|
152
|
+
# @param key [String] Name of file
|
153
|
+
# @param options [Hash]
|
154
|
+
#
|
155
|
+
# @return [Fog::Storage::AzureRM::File] A file. Return nil if the file does not exist.
|
156
|
+
#
|
157
|
+
def head(key, options = {})
|
158
|
+
requires :directory
|
159
|
+
|
160
|
+
blob = service.get_blob_properties(directory.key, key, options)
|
161
|
+
data = parse_storage_object(blob)
|
162
|
+
file_data = data.merge(key: key)
|
163
|
+
new(file_data)
|
164
|
+
rescue => error
|
165
|
+
return nil if error.message == 'NotFound'
|
166
|
+
raise error
|
167
|
+
end
|
168
|
+
|
169
|
+
# Create a new file.
|
170
|
+
#
|
171
|
+
# required attributes: directory
|
172
|
+
#
|
173
|
+
# @return [Fog::Storage::AzureRM::File] A file. You need to use File.save to upload this new file.
|
174
|
+
#
|
175
|
+
def new(attributes = {})
|
176
|
+
requires :directory
|
177
|
+
|
178
|
+
super({ directory: directory }.merge!(attributes))
|
24
179
|
end
|
25
180
|
end
|
26
181
|
end
|