class SDM::ControlPanel

ControlPanel contains all administrative controls.

Public Class Methods

new(host, insecure, parent) click to toggle source
# File lib/svc.rb, line 491
def initialize(host, insecure, parent)
  begin
    if insecure
      @stub = V1::ControlPanel::Stub.new(host, :this_channel_is_insecure)
    else
      cred = GRPC::Core::ChannelCredentials.new()
      @stub = V1::ControlPanel::Stub.new(host, cred)
    end
  rescue => exception
    raise Plumbing::convert_error_to_porcelain(exception)
  end
  @parent = parent
end

Public Instance Methods

get_sshca_public_key( deadline: nil ) click to toggle source

GetSSHCAPublicKey retrieves the SSH CA public key.

# File lib/svc.rb, line 506
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.get_metadata("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::convert_get_response_metadata_to_porcelain(plumbing_response.meta)
  resp.public_key = (plumbing_response.public_key)
  resp.rate_limit = Plumbing::convert_rate_limit_metadata_to_porcelain(plumbing_response.rate_limit)
  resp
end
verify_jwt( token, deadline: nil ) click to toggle source

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

# File lib/svc.rb, line 534
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.get_metadata("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::convert_get_response_metadata_to_porcelain(plumbing_response.meta)
  resp.valid = (plumbing_response.valid)
  resp.rate_limit = Plumbing::convert_rate_limit_metadata_to_porcelain(plumbing_response.rate_limit)
  resp
end