Class: Fog::Rackspace::AutoScale::Webhook

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/rackspace/models/auto_scale/webhook.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#group ⇒ String (readonly)



13
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 13

attribute :group

#id ⇒ String (readonly)



9
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 9

identity :id


29
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 29

attribute :links

#metadata ⇒ Hash (readonly)



25
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 25

attribute :metadata

#name ⇒ String (readonly)



21
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 21

attribute :name

#policy ⇒ String (readonly)



17
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 17

attribute :policy

Instance Method Details

#create ⇒ Boolean

Create webhook

  • requires attribute: :name

Raises:

    • HTTP 404
    • HTTP 400
    • HTTP 500

See Also:



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 43

def create
  requires :name

  options = {}
  options['name'] = name if name
  options['metadata'] =  if 

  data = service.create_webhook(group.id, policy.id, options)
  merge_attributes(data.body['webhooks'][0])
  true
end

#destroy ⇒ Boolean

Destroy the webhook



100
101
102
103
104
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 100

def destroy
  requires :identity
  service.delete_webhook(group.id, policy.id, identity)
  true
end

#execution_url ⇒ String

Retrieves the URL for anonymously executing the policy webhook



108
109
110
111
112
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 108

def execution_url
  requires :links
  link = links.find { |l| l['rel'] == 'capability' }
  link['href'] rescue nil
end

#save ⇒ Boolean

Saves the webhook Creates hook if it is new, otherwise it will update it



81
82
83
84
85
86
87
88
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 81

def save
  if persisted?
    update
  else
    create
  end
  true
end

#update ⇒ Boolean

Updates the webhook



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 65

def update
  requires :identity

  options = {
    'name' => name,
    'metadata' => 
  }

  data = service.update_webhook(group.id, policy.id, identity, options)
  merge_attributes(data.body)
  true
end