Class: SDM::SecretEngines

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

Overview

Instance Method Summary collapse

Constructor Details

#initialize(channel, parent) ⇒ SecretEngines



7618
7619
7620
7621
7622
7623
7624
7625
# File 'lib/svc.rb', line 7618

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

Instance Method Details

#create(secret_engine, deadline: nil) ⇒ Object

Create creates a secret engine



7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
# File 'lib/svc.rb', line 7708

def create(
  secret_engine,
  deadline: nil
)
  req = V1::SecretEngineCreateRequest.new()

  req.secret_engine = Plumbing::convert_secret_engine_to_plumbing(secret_engine)
  # Execute before interceptor hooks
  req = @parent.interceptor.execute_before("SecretEngines.Create", self, req)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.create(req, metadata: @parent.("SecretEngines.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

  # Execute after interceptor hooks
  plumbing_response = @parent.interceptor.execute_after("SecretEngines.Create", self, req, plumbing_response)

  resp = SecretEngineCreateResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp.secret_engine = Plumbing::convert_secret_engine_to_porcelain(plumbing_response.secret_engine)
  resp
end

#delete(id, deadline: nil) ⇒ Object

Delete deletes a secret engine



7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
# File 'lib/svc.rb', line 7778

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

  req.id = (id)
  # Execute before interceptor hooks
  req = @parent.interceptor.execute_before("SecretEngines.Delete", self, req)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.delete(req, metadata: @parent.("SecretEngines.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

  # Execute after interceptor hooks
  plumbing_response = @parent.interceptor.execute_after("SecretEngines.Delete", self, req, plumbing_response)

  resp = SecretEngineDeleteResponse.new()
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

#generate_keys(secret_engine_id, deadline: nil) ⇒ Object

GenerateKeys generates a private key, stores it in a secret store and stores a public key in a secret engine



7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
# File 'lib/svc.rb', line 7851

def generate_keys(
  secret_engine_id,
  deadline: nil
)
  req = V1::GenerateKeysRequest.new()

  req.secret_engine_id = (secret_engine_id)
  # Execute before interceptor hooks
  req = @parent.interceptor.execute_before("SecretEngines.GenerateKeys", self, req)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.generate_keys(req, metadata: @parent.("SecretEngines.GenerateKeys", 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

  # Execute after interceptor hooks
  plumbing_response = @parent.interceptor.execute_after("SecretEngines.GenerateKeys", self, req, plumbing_response)

  resp = GenerateKeysResponse.new()
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

#get(id, deadline: nil) ⇒ Object

Get returns a secret engine details



7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
# File 'lib/svc.rb', line 7669

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

  req.id = (id)
  # Execute before interceptor hooks
  req = @parent.interceptor.execute_before("SecretEngines.Get", self, req)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.get(req, metadata: @parent.("SecretEngines.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

  # Execute after interceptor hooks
  plumbing_response = @parent.interceptor.execute_after("SecretEngines.Get", self, req, plumbing_response)

  resp = SecretEngineGetResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp.secret_engine = Plumbing::convert_secret_engine_to_porcelain(plumbing_response.secret_engine)
  resp
end

#healthcheck(secret_engine_id, deadline: nil) ⇒ Object

Healthcheck triggers a healthcheck for all nodes serving a secret engine



7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
# File 'lib/svc.rb', line 7884

def healthcheck(
  secret_engine_id,
  deadline: nil
)
  req = V1::HealthcheckRequest.new()

  req.secret_engine_id = (secret_engine_id)
  # Execute before interceptor hooks
  req = @parent.interceptor.execute_before("SecretEngines.Healthcheck", self, req)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.healthcheck(req, metadata: @parent.("SecretEngines.Healthcheck", 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

  # Execute after interceptor hooks
  plumbing_response = @parent.interceptor.execute_after("SecretEngines.Healthcheck", self, req, plumbing_response)

  resp = HealthcheckResponse.new()
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp.status = Plumbing::convert_repeated_healthcheck_status_to_porcelain(plumbing_response.status)
  resp
end

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

List returns a list of Secret Engines



7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
# File 'lib/svc.rb', line 7628

def list(
  filter,
  *args,
  deadline: nil
)
  req = V1::SecretEngineListRequest.new()
  req.meta = V1::ListRequestMetadata.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.("SecretEngines.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.secret_engines.each do |plumbing_item|
        g.yield Plumbing::convert_secret_engine_to_porcelain(plumbing_item)
      end
      break if plumbing_response.meta.next_cursor == ""
      req.meta.cursor = plumbing_response.meta.next_cursor
    end
  }
  # Wrap enumerator to cache secret engine public keys
  resp = EnumeratorInterceptor.wrap_secret_engine_list(resp, @parent.instance_variable_get(:@encryption_interceptor))
  resp
end

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

ListSecretStores returns a list of Secret Stores that can be used as a backing store for Secret Engine



7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
# File 'lib/svc.rb', line 7812

def list_secret_stores(
  filter,
  *args,
  deadline: nil
)
  req = V1::SecretStoreListRequest.new()
  req.meta = V1::ListRequestMetadata.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_secret_stores(req, metadata: @parent.("SecretEngines.ListSecretStores", 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.secret_stores.each do |plumbing_item|
        g.yield Plumbing::convert_secret_store_to_porcelain(plumbing_item)
      end
      break if plumbing_response.meta.next_cursor == ""
      req.meta.cursor = plumbing_response.meta.next_cursor
    end
  }
  resp
end

#rotate(id, password_policy, deadline: nil) ⇒ Object

Rotate rotates secret engine's credentials



7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
# File 'lib/svc.rb', line 7918

def rotate(
  id,
  password_policy,
  deadline: nil
)
  req = V1::SecretEngineRotateRequest.new()

  req.id = (id)
  req.password_policy = Plumbing::convert_secret_engine_password_policy_to_plumbing(password_policy)
  # Execute before interceptor hooks
  req = @parent.interceptor.execute_before("SecretEngines.Rotate", self, req)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.rotate(req, metadata: @parent.("SecretEngines.Rotate", 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

  # Execute after interceptor hooks
  plumbing_response = @parent.interceptor.execute_after("SecretEngines.Rotate", self, req, plumbing_response)

  resp = SecretEngineRotateResponse.new()
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

#update(secret_engine, deadline: nil) ⇒ Object

Update updates a secret engine



7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
# File 'lib/svc.rb', line 7743

def update(
  secret_engine,
  deadline: nil
)
  req = V1::SecretEngineUpdateRequest.new()

  req.secret_engine = Plumbing::convert_secret_engine_to_plumbing(secret_engine)
  # Execute before interceptor hooks
  req = @parent.interceptor.execute_before("SecretEngines.Update", self, req)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.update(req, metadata: @parent.("SecretEngines.Update", 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

  # Execute after interceptor hooks
  plumbing_response = @parent.interceptor.execute_after("SecretEngines.Update", self, req, plumbing_response)

  resp = SecretEngineUpdateResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp.secret_engine = Plumbing::convert_secret_engine_to_porcelain(plumbing_response.secret_engine)
  resp
end