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.



8156
8157
8158
8159
8160
8161
8162
8163
# File 'lib/svc.rb', line 8156

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



8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
# File 'lib/svc.rb', line 8246

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



8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
# File 'lib/svc.rb', line 8316

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



8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
# File 'lib/svc.rb', line 8389

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



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
8240
8241
8242
8243
# File 'lib/svc.rb', line 8207

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



8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
# File 'lib/svc.rb', line 8422

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



8166
8167
8168
8169
8170
8171
8172
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 8166

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



8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
# File 'lib/svc.rb', line 8350

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



8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
# File 'lib/svc.rb', line 8456

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



8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
# File 'lib/svc.rb', line 8281

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