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

Returns a new instance of SecretEngines.



7907
7908
7909
7910
7911
7912
7913
7914
# File 'lib/svc.rb', line 7907

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



7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
# File 'lib/svc.rb', line 7997

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



8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
# File 'lib/svc.rb', line 8067

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



8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
# File 'lib/svc.rb', line 8140

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



7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
# File 'lib/svc.rb', line 7958

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



8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
# File 'lib/svc.rb', line 8173

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



7917
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
7951
7952
7953
7954
7955
# File 'lib/svc.rb', line 7917

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



8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
# File 'lib/svc.rb', line 8101

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



8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
# File 'lib/svc.rb', line 8207

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



8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
# File 'lib/svc.rb', line 8032

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