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

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

Instance Attribute Summary collapse

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

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

#groupString (readonly)

Returns The associated group.

Returns:

  • (String)

    The associated group



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

attribute :group

#idString (readonly)

Returns The webhook id.

Returns:



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

identity :id

Returns The webhook links.

Returns:

  • (Array)

    The webhook links



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

attribute :links

#metadataHash (readonly)

Returns The metadata.

Returns:

  • (Hash)

    The metadata



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

attribute :metadata

#nameString (readonly)

Returns The webhook name.

Returns:

  • (String)

    The webhook name



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

attribute :name

#policyString (readonly)

Returns The associated policy.

Returns:

  • (String)

    The associated policy



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

attribute :policy

Instance Method Details

#createBoolean

Create webhook

  • requires attribute: :name

Returns:

  • (Boolean)

    returns true if webhook is being created

Raises:

  • (Fog::Rackspace::AutoScale:::NotFound)
    • HTTP 404

  • (Fog::Rackspace::AutoScale:::BadRequest)
    • HTTP 400

  • (Fog::Rackspace::AutoScale:::InternalServerError)
    • HTTP 500

  • (Fog::Rackspace::AutoScale:::ServiceError)

See Also:



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

  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

#destroyBoolean

Destroy the webhook

Returns:

  • (Boolean)

    returns true if webhook has started deleting

Raises:

  • (Fog::Rackspace::AutoScale:::NotFound)
    • HTTP 404

  • (Fog::Rackspace::AutoScale:::BadRequest)
    • HTTP 400

  • (Fog::Rackspace::AutoScale:::InternalServerError)
    • HTTP 500

  • (Fog::Rackspace::AutoScale:::ServiceError)

See Also:



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_urlString

Retrieves the URL for anonymously executing the policy webhook

Returns:



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

#saveBoolean

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

Returns:

  • (Boolean)

    true if policy has saved



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

#updateBoolean

Updates the webhook

Returns:

  • (Boolean)

    returns true if webhook has started updating

Raises:

  • (Fog::Rackspace::AutoScale:::NotFound)
    • HTTP 404

  • (Fog::Rackspace::AutoScale:::BadRequest)
    • HTTP 400

  • (Fog::Rackspace::AutoScale:::InternalServerError)
    • HTTP 500

  • (Fog::Rackspace::AutoScale:::ServiceError)

See Also:



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

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

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