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.



3839
3840
3841
3842
3843
3844
3845
3846
# File 'lib/svc.rb', line 3839

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.



3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
# File 'lib/svc.rb', line 3849

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.



3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
# File 'lib/svc.rb', line 3914

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.



3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
# File 'lib/svc.rb', line 3880

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.



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
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
# File 'lib/svc.rb', line 3943

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