Class: Azure::Service::StorageService

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

Overview

A base class for StorageService implementations

Instance Method Summary collapse

Constructor Details

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

Create a new instance of the StorageService

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

Parameters:

  • signer (Azure::Core::Auth::Signer) (defaults to: Core::Auth::SharedKey.new)

    An implementation of Signer used for signing requests.

  • account_name (String) (defaults to: nil)

    The account name (optional, Default=Azure.config.storage_account_name)

  • options (Azure::Configurable) (defaults to: {})

    the client configuration context



27
28
29
# File 'lib/azure/service/storage_service.rb', line 27

def initialize(signer=Core::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



74
75
76
77
78
# File 'lib/azure/service/storage_service.rb', line 74

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



38
39
40
41
42
# File 'lib/azure/service/storage_service.rb', line 38

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



80
81
82
# File 'lib/azure/service/storage_service.rb', line 80

def service_properties_headers
  {'x-ms-version' => '2014-02-14'}
end

#service_properties_uri(query = {}) ⇒ Object

Public: Generate the URI for the service properties

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

Returns a URI.



65
66
67
68
# File 'lib/azure/service/storage_service.rb', line 65

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.



52
53
54
55
56
57
58
# File 'lib/azure/service/storage_service.rb', line 52

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