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.



3895
3896
3897
3898
3899
3900
3901
3902
# File 'lib/svc.rb', line 3895

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.



3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
# File 'lib/svc.rb', line 3905

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.



3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
# File 'lib/svc.rb', line 3970

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.



3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
# File 'lib/svc.rb', line 3936

def get(
  id,
  deadline: nil
)
  req = V1::ProxyClusterKeyGetRequest.new()
  if not @parent.snapshot_time.nil?
    req.meta = V1::GetRequestMetadata.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.



3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
# File 'lib/svc.rb', line 3999

def list(
  filter,
  *args,
  deadline: nil
)
  req = V1::ProxyClusterKeyListRequest.new()
  req.meta = V1::ListRequestMetadata.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