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

#groupString (readonly)

Returns The associated group.

Returns:

  • (String)

    The associated group



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

attribute :group

#idString (readonly)

Returns The webhook id.

Returns:



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

identity :id

Returns The webhook links.

Returns:

  • (Array)

    The webhook links



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

attribute :links

#metadataHash (readonly)

Returns The metadata.

Returns:

  • (Hash)

    The metadata



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

attribute :metadata

#nameString (readonly)

Returns The webhook name.

Returns:

  • (String)

    The webhook name



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

attribute :name

#policyString (readonly)

Returns The associated policy.

Returns:

  • (String)

    The associated policy



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

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:



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

#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:



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_urlString

Retrieves the URL for anonymously executing the policy webhook

Returns:



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

#saveBoolean

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

Returns:

  • (Boolean)

    true if policy has saved



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

#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:



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