Class: SDM::DiscoveryConnectors

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

Overview

A Discovery Connector is a configuration object for performing Resource Scans in remote systems such as AWS, GCP, Azure, and other systems.

See: AWSConnector AzureConnector GCPConnector

Instance Method Summary collapse

Constructor Details

#initialize(channel, parent) ⇒ DiscoveryConnectors

Returns a new instance of DiscoveryConnectors.



2492
2493
2494
2495
2496
2497
2498
2499
# File 'lib/svc.rb', line 2492

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

Instance Method Details

#create(connector, deadline: nil) ⇒ Object

Create adds a new Connector.



2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
# File 'lib/svc.rb', line 2502

def create(
  connector,
  deadline: nil
)
  req = V1::ConnectorCreateRequest.new()

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

  resp = ConnectorCreateResponse.new()
  resp.connector = Plumbing::convert_connector_to_porcelain(plumbing_response.connector)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

#delete(id, deadline: nil) ⇒ Object

Delete removes a Connector by ID.



2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
# File 'lib/svc.rb', line 2609

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

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

  resp = ConnectorDeleteResponse.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 Connector by ID



2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
# File 'lib/svc.rb', line 2536

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

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

  resp = ConnectorGetResponse.new()
  resp.connector = Plumbing::convert_connector_to_porcelain(plumbing_response.connector)
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

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

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



2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
# File 'lib/svc.rb', line 2643

def list(
  filter,
  *args,
  deadline: nil
)
  req = V1::ConnectorListRequest.new()
  req.meta = V1::.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.("DiscoveryConnectors.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.connectors.each do |plumbing_item|
        g.yield Plumbing::convert_connector_to_porcelain(plumbing_item)
      end
      break if plumbing_response.meta.next_cursor == ""
      req.meta.cursor = plumbing_response.meta.next_cursor
    end
  }
  resp
end

#update(connector, deadline: nil) ⇒ Object

Update replaces all the fields of a Connector by ID.



2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
# File 'lib/svc.rb', line 2575

def update(
  connector,
  deadline: nil
)
  req = V1::ConnectorUpdateRequest.new()

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

  resp = ConnectorUpdateResponse.new()
  resp.connector = Plumbing::convert_connector_to_porcelain(plumbing_response.connector)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end