Class: Azure::Armrest::Insights::DiagnosticService

Inherits:
ArmrestService show all
Defined in:
lib/azure/armrest/insights/diagnostic_service.rb

Overview

Base class for managing diagnostics

Instance Attribute Summary

Attributes inherited from ArmrestService

#api_version, #armrest_configuration, #base_url, #provider, #service_name

Instance Method Summary collapse

Methods inherited from ArmrestService

configure, #get_provider, #get_subscription, #list_locations, #list_resource_groups, #list_resources, #list_subscriptions, #locations, #poll, #tags, #tenants, #wait

Constructor Details

#initialize(armrest_configuration, options = {}) ⇒ DiagnosticService

Returns a new instance of DiagnosticService.



6
7
8
# File 'lib/azure/armrest/insights/diagnostic_service.rb', line 6

def initialize(armrest_configuration, options = {})
  super(armrest_configuration, 'diagnosticSettings', 'Microsoft.Insights', options)
end

Instance Method Details

#create(resource_id, options = {}) ⇒ Object Also known as: update, set

Create or update a diagnostic setting for the given resource_id.

Example:

# Update network security group log settings ids = Azure::Armrest::Insights::DiagnosticService.new(config) sas = Azure::Armrest::StorageAccountService.new(config) nsg = Azure::Armrest::Network::NetworkSecurityGroupService.new(config)

acct = sas.get(your_storage, your_resource_group) sgrp = nsg.get(your_network_security_group, your_resource_group)

options = {

:properties => {
  :storageAccountId => acct.id,
  :logs => [
    {
      :category => "NetworkSecurityGroupEvent",
      :enabled  => true,
      :retentionPolicy => {
        :enabled => true,
        :days    => 3
      }
    },
    {
      :category => "NetworkSecurityGroupRuleCounter",
      :enabled  => true,
      :retentionPolicy => {
        :enabled => true,
        :days    => 3
      }
    }
  ]
}

}

ids.set(sgrp.id, options)



65
66
67
68
69
70
71
72
73
74
# File 'lib/azure/armrest/insights/diagnostic_service.rb', line 65

def create(resource_id, options = {})
  url = build_url(resource_id)
  body = options.merge(:id => resource_id).to_json
  response = rest_put(url, body)

  headers = Azure::Armrest::ResponseHeaders.new(response.headers)
  headers.response_code = response.code

  headers
end

#get(resource_id) ⇒ Object

Get diagnostic information for the given resource_id. Note that this information is only available for a limited subset of resources.

Example:

ids = Azure::Armrest::Insights::DiagnosticService.new(config) nsg = Azure::Armrest::Network::NetworkSecurityGroupService.new(config)

sgrp = nsg.get(your_security_group, your_resource_group) p ids.get(sgrp.id)



21
22
23
24
25
# File 'lib/azure/armrest/insights/diagnostic_service.rb', line 21

def get(resource_id)
  url = build_url(resource_id)
  response = rest_get(url)
  Diagnostic.new(JSON.parse(response))
end