Class: SDM::ProxyClusterKeys

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

Overview

Proxy Cluster Keys are authentication keys for all proxies within a cluster. The proxies within a cluster share the same key. One cluster can have multiple keys in order to facilitate key rotation.

See ProxyClusterKey.

Instance Method Summary collapse

Constructor Details

#initialize(channel, parent) ⇒ ProxyClusterKeys

Returns a new instance of ProxyClusterKeys.



5257
5258
5259
5260
5261
5262
5263
5264
# File 'lib/svc.rb', line 5257

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

Instance Method Details

#create(proxy_cluster_key, deadline: nil) ⇒ Object

Create registers a new ProxyClusterKey.



5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
# File 'lib/svc.rb', line 5267

def create(
  proxy_cluster_key,
  deadline: nil
)
  req = V1::ProxyClusterKeyCreateRequest.new()

  req.proxy_cluster_key = Plumbing::convert_proxy_cluster_key_to_plumbing(proxy_cluster_key)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.create(req, metadata: @parent.("ProxyClusterKeys.Create", req), deadline: deadline)
    rescue => exception
      if (@parent.shouldRetry(tries, exception, deadline))
        tries + +sleep(@parent.exponentialBackoff(tries, deadline))
        next
      end
      raise Plumbing::convert_error_to_porcelain(exception)
    end
    break
  end

  resp = ProxyClusterKeyCreateResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.proxy_cluster_key = Plumbing::convert_proxy_cluster_key_to_porcelain(plumbing_response.proxy_cluster_key)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp.secret_key = (plumbing_response.secret_key)
  resp
end

#delete(id, deadline: nil) ⇒ Object

Delete removes a ProxyClusterKey by ID.



5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
# File 'lib/svc.rb', line 5332

def delete(
  id,
  deadline: nil
)
  req = V1::ProxyClusterKeyDeleteRequest.new()

  req.id = (id)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.delete(req, metadata: @parent.("ProxyClusterKeys.Delete", req), deadline: deadline)
    rescue => exception
      if (@parent.shouldRetry(tries, exception, deadline))
        tries + +sleep(@parent.exponentialBackoff(tries, deadline))
        next
      end
      raise Plumbing::convert_error_to_porcelain(exception)
    end
    break
  end

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

#get(id, deadline: nil) ⇒ Object

Get reads one ProxyClusterKey by ID.



5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
# File 'lib/svc.rb', line 5298

def get(
  id,
  deadline: nil
)
  req = V1::ProxyClusterKeyGetRequest.new()
  if not @parent.snapshot_time.nil?
    req.meta = V1::.new()
    req.meta.snapshot_at = @parent.snapshot_time
  end

  req.id = (id)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.get(req, metadata: @parent.("ProxyClusterKeys.Get", req), deadline: deadline)
    rescue => exception
      if (@parent.shouldRetry(tries, exception, deadline))
        tries + +sleep(@parent.exponentialBackoff(tries, deadline))
        next
      end
      raise Plumbing::convert_error_to_porcelain(exception)
    end
    break
  end

  resp = ProxyClusterKeyGetResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.proxy_cluster_key = Plumbing::convert_proxy_cluster_key_to_porcelain(plumbing_response.proxy_cluster_key)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

#list(filter, *args, deadline: nil) ⇒ Object

List gets a list of ProxyClusterKeys matching a given set of criteria.



5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
# File 'lib/svc.rb', line 5361

def list(
  filter,
  *args,
  deadline: nil
)
  req = V1::ProxyClusterKeyListRequest.new()
  req.meta = V1::.new()
  if not @parent.page_limit.nil?
    req.meta.limit = @parent.page_limit
  end
  if not @parent.snapshot_time.nil?
    req.meta.snapshot_at = @parent.snapshot_time
  end

  req.filter = Plumbing::quote_filter_args(filter, *args)
  resp = Enumerator::Generator.new { |g|
    tries = 0
    loop do
      begin
        plumbing_response = @stub.list(req, metadata: @parent.("ProxyClusterKeys.List", req), deadline: deadline)
      rescue => exception
        if (@parent.shouldRetry(tries, exception, deadline))
          tries + +sleep(@parent.exponentialBackoff(tries, deadline))
          next
        end
        raise Plumbing::convert_error_to_porcelain(exception)
      end
      tries = 0
      plumbing_response.proxy_cluster_keys.each do |plumbing_item|
        g.yield Plumbing::convert_proxy_cluster_key_to_porcelain(plumbing_item)
      end
      break if plumbing_response.meta.next_cursor == ""
      req.meta.cursor = plumbing_response.meta.next_cursor
    end
  }
  resp
end