Class: SDM::SecretStores

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

Overview

SecretStores are servers where resource secrets (passwords, keys) are stored.

See: AWSStore AzureStore CyberarkConjurStore CyberarkPAMExperimentalStore DelineaStore GCPStore VaultAppRoleStore VaultTLSStore VaultTokenStore

Instance Method Summary collapse

Constructor Details

#initialize(host, insecure, parent) ⇒ SecretStores

Returns a new instance of SecretStores.



1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
# File 'lib/svc.rb', line 1511

def initialize(host, insecure, parent)
  begin
    if insecure
      @stub = V1::SecretStores::Stub.new(host, :this_channel_is_insecure)
    else
      cred = GRPC::Core::ChannelCredentials.new()
      @stub = V1::SecretStores::Stub.new(host, cred)
    end
  rescue => exception
    raise Plumbing::convert_error_to_porcelain(exception)
  end
  @parent = parent
end

Instance Method Details

#create(secret_store, deadline: nil) ⇒ Object



1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
# File 'lib/svc.rb', line 1525

def create(
  secret_store,
  deadline: nil
)
  req = V1::SecretStoreCreateRequest.new()

  req.secret_store = Plumbing::convert_secret_store_to_plumbing(secret_store)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.create(req, metadata: @parent.("SecretStores.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 = SecretStoreCreateResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp.secret_store = Plumbing::convert_secret_store_to_porcelain(plumbing_response.secret_store)
  resp
end

#delete(id, deadline: nil) ⇒ Object

Delete removes a SecretStore by ID.



1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
# File 'lib/svc.rb', line 1615

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

  req.id = (id)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.delete(req, metadata: @parent.("SecretStores.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 = SecretStoreDeleteResponse.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 SecretStore by ID.



1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
# File 'lib/svc.rb', line 1555

def get(
  id,
  deadline: nil
)
  req = V1::SecretStoreGetRequest.new()

  req.id = (id)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.get(req, metadata: @parent.("SecretStores.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 = SecretStoreGetResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp.secret_store = Plumbing::convert_secret_store_to_porcelain(plumbing_response.secret_store)
  resp
end

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

List gets a list of SecretStores matching a given set of criteria.



1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
# File 'lib/svc.rb', line 1644

def list(
  filter,
  *args,
  deadline: nil
)
  req = V1::SecretStoreListRequest.new()
  req.meta = V1::ListRequestMetadata.new()
  page_size_option = @parent._test_options["PageSize"]
  if page_size_option.is_a? Integer
    req.meta.limit = page_size_option
  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.("SecretStores.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.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

#update(secret_store, deadline: nil) ⇒ Object

Update replaces all the fields of a SecretStore by ID.



1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
# File 'lib/svc.rb', line 1585

def update(
  secret_store,
  deadline: nil
)
  req = V1::SecretStoreUpdateRequest.new()

  req.secret_store = Plumbing::convert_secret_store_to_plumbing(secret_store)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.update(req, metadata: @parent.("SecretStores.Update", 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 = SecretStoreUpdateResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp.secret_store = Plumbing::convert_secret_store_to_porcelain(plumbing_response.secret_store)
  resp
end