Class: SDM::ControlPanel

Inherits:
Object
  • Object
show all
Extended by:
Gem::Deprecate
Defined in:
lib/svc.rb

Overview

ControlPanel contains all administrative controls.

Instance Method Summary collapse

Constructor Details

#initialize(channel, parent) ⇒ ControlPanel

Returns a new instance of ControlPanel.



1272
1273
1274
1275
1276
1277
1278
1279
# File 'lib/svc.rb', line 1272

def initialize(channel, parent)
  begin
    @stub = V1::ControlPanel::Stub.new(nil, nil, channel_override: channel)
  rescue => exception
    raise Plumbing::convert_error_to_porcelain(exception)
  end
  @parent = parent
end

Instance Method Details

#get_sshca_public_key(deadline: nil) ⇒ Object

GetSSHCAPublicKey retrieves the SSH CA public key.



1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
# File 'lib/svc.rb', line 1282

def get_sshca_public_key(
  deadline: nil
)
  req = V1::ControlPanelGetSSHCAPublicKeyRequest.new()

  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.get_sshca_public_key(req, metadata: @parent.("ControlPanel.GetSSHCAPublicKey", req), deadline: deadline)
    rescue => exception
      if (@parent.shouldRetry(tries, exception))
        tries + +@parent.jitterSleep(tries)
        next
      end
      raise Plumbing::convert_error_to_porcelain(exception)
    end
    break
  end

  resp = ControlPanelGetSSHCAPublicKeyResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.public_key = (plumbing_response.public_key)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

#verify_jwt(token, deadline: nil) ⇒ Object

VerifyJWT reports whether the given JWT token (x-sdm-token) is valid.



1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
# File 'lib/svc.rb', line 1310

def verify_jwt(
  token,
  deadline: nil
)
  req = V1::ControlPanelVerifyJWTRequest.new()

  req.token = (token)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.verify_jwt(req, metadata: @parent.("ControlPanel.VerifyJWT", req), deadline: deadline)
    rescue => exception
      if (@parent.shouldRetry(tries, exception))
        tries + +@parent.jitterSleep(tries)
        next
      end
      raise Plumbing::convert_error_to_porcelain(exception)
    end
    break
  end

  resp = ControlPanelVerifyJWTResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp.valid = (plumbing_response.valid)
  resp
end