Class: Armrest::Services::BlobContainer

Inherits:
Base
  • Object
show all
Defined in:
lib/armrest/services/blob_container.rb

Instance Method Summary collapse

Methods included from Api::Settings

#client_id, #client_secret, #endpoint, #group, #location, #resource, #subscription_id, #tenant_id

Methods included from Api::HandleResponse

#load_json, #ok?

Methods included from Logging

#default_logger, #logger, #logger=

Constructor Details

#initialize(options = {}) ⇒ BlobContainer

Returns a new instance of BlobContainer.



3
4
5
6
# File 'lib/armrest/services/blob_container.rb', line 3

def initialize(options={})
  super
  @storage_account = options[:storage_account]
end

Instance Method Details

#create(attrs = {}) ⇒ Object

docs.microsoft.com/en-us/rest/api/storagerp/blob-containers/create PUT management.azure.com/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/accountName/blobServices/default/containers/containerName?api-version=2021-04-01



23
24
25
26
27
# File 'lib/armrest/services/blob_container.rb', line 23

def create(attrs={})
  name = attrs.delete(:name)
  path = "subscriptions/#{subscription_id}/resourceGroups/#{group}/providers/Microsoft.Storage/storageAccounts/#{@storage_account}/blobServices/default/containers/#{name}"
  api.put(path)
end

#exist?(attrs = {}) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/armrest/services/blob_container.rb', line 16

def exist?(attrs={})
  resp = get(attrs)
  resp.code =~ /^20/
end

#get(attrs = {}) ⇒ Object

docs.microsoft.com/en-us/rest/api/storagerp/blob-containers/get GET management.azure.com/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/accountName/blobServices/default/containers/containerName?api-version=2021-04-01



10
11
12
13
14
# File 'lib/armrest/services/blob_container.rb', line 10

def get(attrs={})
  name = attrs[:name]
  path = "subscriptions/#{subscription_id}/resourceGroups/#{group}/providers/Microsoft.Storage/storageAccounts/#{@storage_account}/blobServices/default/containers/#{name}"
  api.get(path)
end