Class: Fog::Rackspace::AutoScale::Webhook
- Defined in:
- lib/fog/rackspace/models/auto_scale/webhook.rb
Instance Attribute Summary collapse
-
#group ⇒ String
readonly
The associated group.
-
#id ⇒ String
readonly
The webhook id.
-
#links ⇒ Array
readonly
The webhook links.
-
#metadata ⇒ Hash
readonly
The metadata.
-
#name ⇒ String
readonly
The webhook name.
-
#policy ⇒ String
readonly
The associated policy.
Attributes inherited from Model
Instance Method Summary collapse
-
#create ⇒ Boolean
Create webhook * requires attribute: :name.
-
#destroy ⇒ Boolean
Destroy the webhook.
-
#execution_url ⇒ String
Retrieves the URL for anonymously executing the policy webhook.
-
#save ⇒ Boolean
Saves the webhook Creates hook if it is new, otherwise it will update it.
-
#update ⇒ Boolean
Updates the webhook.
Methods inherited from Model
#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Model
Instance Attribute Details
#group ⇒ String (readonly)
Returns The associated group.
14 |
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 14 attribute :group |
#id ⇒ String (readonly)
Returns The webhook id.
10 |
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 10 identity :id |
#links ⇒ Array (readonly)
Returns The webhook links.
30 |
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 30 attribute :links |
#metadata ⇒ Hash (readonly)
Returns The metadata.
26 |
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 26 attribute :metadata |
#name ⇒ String (readonly)
Returns The webhook name.
22 |
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 22 attribute :name |
#policy ⇒ String (readonly)
Returns The associated policy.
18 |
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 18 attribute :policy |
Instance Method Details
#create ⇒ Boolean
Create webhook
-
requires attribute: :name
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 44 def create requires :name = {} ['name'] = name if name ['metadata'] = if data = service.create_webhook(group.id, policy.id, ) merge_attributes(data.body['webhooks'][0]) true end |
#destroy ⇒ Boolean
Destroy the webhook
101 102 103 104 105 |
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 101 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
109 110 111 112 113 |
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 109 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
82 83 84 85 86 87 88 89 |
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 82 def save if persisted? update else create end true end |
#update ⇒ Boolean
Updates the webhook
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/fog/rackspace/models/auto_scale/webhook.rb', line 66 def update requires :identity = { 'name' => name, 'metadata' => } data = service.update_webhook(group.id, policy.id, identity, ) merge_attributes(data.body) true end |