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.



1091
1092
1093
1094
1095
1096
1097
1098
# File 'lib/svc.rb', line 1091

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.



1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
# File 'lib/svc.rb', line 1101

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.



1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
# File 'lib/svc.rb', line 1129

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