class Azure::Service::StorageService

A base class for StorageService implementations

Public Class Methods

new(signer=Core::Auth::SharedKey.new, account_name=Azure.config.storage_account_name) click to toggle source

Create a new instance of the StorageService

signer - Azure::Core::Auth::Signer. An implementation of Signer used for signing requests. (optional, Default=Azure::Core::Auth::SharedKey.new) account_name - String. The account name (optional, Default=Azure.config.storage_account_name)

Calls superclass method Azure::Core::SignedService::new
# File lib/azure/service/storage_service.rb, line 25
def initialize(signer=Core::Auth::SharedKey.new, account_name=Azure.config.storage_account_name)
  super(signer, account_name)
end

Public Instance Methods

add_metadata_to_headers(metadata, headers) click to toggle source

Adds metadata properties to header hash with required prefix

metadata - A Hash of metadata name/value pairs headers - A Hash of HTTP headers

# File lib/azure/service/storage_service.rb, line 72
def add_metadata_to_headers(metadata, headers)
  metadata.each do |key, value|
    headers["x-ms-meta-#{key}"] = value
  end
end
get_service_properties() click to toggle source

Public: Get Storage Service properties

See msdn.microsoft.com/en-us/library/azure/hh452239 See msdn.microsoft.com/en-us/library/azure/hh452243

Returns a Hash with the service properties or nil if the operation failed

# File lib/azure/service/storage_service.rb, line 36
def get_service_properties
  uri = service_properties_uri
  response = call(:get, uri, nil, service_properties_headers)
  Serialization.service_properties_from_xml response.body
end
service_properties_headers() click to toggle source
# File lib/azure/service/storage_service.rb, line 78
def service_properties_headers
  {"x-ms-version" => "2013-08-15"}
end
service_properties_uri(query={}) click to toggle source

Public: Generate the URI for the service properties

query - see Azure::Services::GetServiceProperties#call documentation.

Returns a URI.

# File lib/azure/service/storage_service.rb, line 63
def service_properties_uri(query={})
  query.update(restype: 'service', comp: 'properties')
  generate_uri("", query)
end
set_service_properties(service_properties) click to toggle source

Public: Set Storage Service properties

service_properties - An instance of Azure::Entity::Service::StorageServiceProperties

See msdn.microsoft.com/en-us/library/azure/hh452235 See msdn.microsoft.com/en-us/library/azure/hh452232

Returns boolean indicating success.

# File lib/azure/service/storage_service.rb, line 50
def set_service_properties(service_properties)
  body = Serialization.service_properties_to_xml service_properties

  uri = service_properties_uri
  call(:put, uri, body, service_properties_headers)
  nil
end