Class: Azure::Service::StorageService

Inherits:
Core::SignedService show all
Defined in:
lib/azure/service/storage_service.rb

Overview

A base class for StorageService implementations

Instance Attribute Summary

Attributes inherited from Core::SignedService

#account_name, #signer

Attributes inherited from Core::FilteredService

#filters

Attributes inherited from Core::Service

#host

Instance Method Summary collapse

Methods inherited from Core::SignedService

#call

Methods inherited from Core::FilteredService

#call, #with_filter

Methods inherited from Core::Service

#call, #generate_uri

Constructor Details

#initialize(signer = Core::Auth::SharedKey.new, account_name = Azure.config.storage_account_name) ⇒ StorageService

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)



25
26
27
# File 'lib/azure/service/storage_service.rb', line 25

def initialize(signer=Core::Auth::SharedKey.new, =Azure.config.)
  super(signer, )
end

Instance Method Details

#add_metadata_to_headers(metadata, headers) ⇒ Object

Adds metadata properties to header hash with required prefix

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



72
73
74
75
76
# File 'lib/azure/service/storage_service.rb', line 72

def (, headers)
  .each do |key, value|
    headers["x-ms-meta-#{key}"] = value
  end
end

#get_service_propertiesObject

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



36
37
38
39
40
# 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_headersObject



78
79
80
# File 'lib/azure/service/storage_service.rb', line 78

def service_properties_headers
  {"x-ms-version" => "2013-08-15"}
end

#service_properties_uri(query = {}) ⇒ Object

Public: Generate the URI for the service properties

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

Returns a URI.



63
64
65
66
# 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) ⇒ Object

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.



50
51
52
53
54
55
56
# 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