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



4246
4247
4248
4249
4250
4251
4252
4253
# File 'lib/svc.rb', line 4246

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.



4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
# File 'lib/svc.rb', line 4256

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))
        tries + +@parent.jitterSleep(tries)
        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.



4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
# File 'lib/svc.rb', line 4321

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))
        tries + +@parent.jitterSleep(tries)
        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.



4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
# File 'lib/svc.rb', line 4287

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))
        tries + +@parent.jitterSleep(tries)
        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.



4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
# File 'lib/svc.rb', line 4350

def list(
  filter,
  *args,
  deadline: nil
)
  req = V1::ProxyClusterKeyListRequest.new()
  req.meta = V1::.new()
  if @parent.page_limit > 0
    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))
          tries + +@parent.jitterSleep(tries)
          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