Class: AkamaiApi::CCU::Purge::Request
- Inherits:
-
Object
- Object
- AkamaiApi::CCU::Purge::Request
- Includes:
- HTTParty
- Defined in:
- lib/akamai_api/ccu/purge/request.rb
Overview
AkamaiApi::CCU::Purge encapsulates the behavior needed to purge a resource from Akamai via CCU.
Instance Attribute Summary collapse
-
#action ⇒ :invalidate, :remove
Clean action type.
-
#domain ⇒ :production, :staging
Domain type to target.
-
#type ⇒ :cpcode, :arl
Resource type.
Instance Method Summary collapse
-
#execute(*items) ⇒ Response
Clean the requested resources.
-
#initialize(action = :remove, type = :arl, args = {}) ⇒ Request
constructor
A new instance of Request.
-
#request_body(items) ⇒ String
Request body to send to the API.
Constructor Details
#initialize(action = :remove, type = :arl, args = {}) ⇒ Request
Returns a new instance of Request.
29 30 31 32 33 |
# File 'lib/akamai_api/ccu/purge/request.rb', line 29 def initialize action = :remove, type=:arl, args = {} self.action = action self.type = type self.domain = args[:domain] || :production end |
Instance Attribute Details
#action ⇒ :invalidate, :remove
Clean action type.
40 41 42 |
# File 'lib/akamai_api/ccu/purge/request.rb', line 40 def action @action end |
#domain ⇒ :production, :staging
Domain type to target.
60 61 62 |
# File 'lib/akamai_api/ccu/purge/request.rb', line 60 def domain @domain end |
#type ⇒ :cpcode, :arl
Resource type.
50 51 52 |
# File 'lib/akamai_api/ccu/purge/request.rb', line 50 def type @type end |
Instance Method Details
#execute(*items) ⇒ Response
Clean the requested resources.
74 75 76 77 78 |
# File 'lib/akamai_api/ccu/purge/request.rb', line 74 def execute *items items = Array.wrap(items.first) if items.length == 1 response = self.class.post('/', basic_auth: AkamaiApi.auth, body: request_body(items)) parse_response response end |
#request_body(items) ⇒ String
Request body to send to the API.
83 84 85 |
# File 'lib/akamai_api/ccu/purge/request.rb', line 83 def request_body items { type: type, action: action, domain: domain, objects: items }.to_json end |