Class: Azure::Storage::Service::StorageService

Inherits:
Core::SignedService show all
Defined in:
lib/azure/storage/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

#client, #host

Instance Method Summary collapse

Methods inherited from Core::FilteredService

#with_filter

Methods inherited from Core::Service

#generate_uri

Constructor Details

#initialize(signer = Auth::SharedKey.new, account_name = nil, options = {}) ⇒ StorageService

Create a new instance of the StorageService

(optional, Default=Azure::Storage::Auth::SharedKey.new)


30
31
32
# File 'lib/azure/storage/service/storage_service.rb', line 30

def initialize(signer=Auth::SharedKey.new, =nil, options = {})
  super(signer, , options)
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


81
82
83
84
85
# File 'lib/azure/storage/service/storage_service.rb', line 81

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

#call(method, uri, body = nil, headers = {}) ⇒ Object


34
35
36
# File 'lib/azure/storage/service/storage_service.rb', line 34

def call(method, uri, body=nil, headers={})
  super(method, uri, body, service_properties_headers.merge(headers))
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


45
46
47
48
49
# File 'lib/azure/storage/service/storage_service.rb', line 45

def get_service_properties
  uri = service_properties_uri
  response = call(:get, uri)
  Serialization.service_properties_from_xml response.body
end

#service_properties_headersObject


87
88
89
90
91
92
# File 'lib/azure/storage/service/storage_service.rb', line 87

def service_properties_headers
  {
    'x-ms-version' => Azure::Storage::Default::STG_VERSION,
    'User-Agent' => Azure::Storage::Default::USER_AGENT
  }
end

#service_properties_uri(query = {}) ⇒ Object

Public: Generate the URI for the service properties

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

Returns a URI.


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

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::Storage::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.


59
60
61
62
63
64
65
# File 'lib/azure/storage/service/storage_service.rb', line 59

def set_service_properties(service_properties)
  body = Serialization.service_properties_to_xml service_properties

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