Class: GlobiGuard::GovernedActions

Inherits:
Object
  • Object
show all
Defined in:
lib/globiguard.rb

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ GovernedActions

Returns a new instance of GovernedActions.



144
145
146
# File 'lib/globiguard.rb', line 144

def initialize(transport)
  @transport = transport
end

Instance Method Details

#authorize_action_or_throw(body, idempotency_key: nil, correlation_id: nil) ⇒ Object



148
149
150
151
152
153
154
155
# File 'lib/globiguard.rb', line 148

def authorize_action_or_throw(body, idempotency_key: nil, correlation_id: nil)
  headers = {}
  headers["Idempotency-Key"] = idempotency_key if idempotency_key
  headers["x-correlation-id"] = correlation_id if correlation_id
  result = @transport.request("post", "/v1/actions/authorize", body: body, headers: headers)
  raise "GlobiGuard blocked the governed action." if result["decision"] == "BLOCK"
  result
end