Class: SDM::PeeringGroupPeers

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

Overview

PeeringGroupPeers provides the building blocks necessary to link two peering groups.

See PeeringGroupPeer.

Instance Method Summary collapse

Constructor Details

#initialize(channel, parent) ⇒ PeeringGroupPeers

Returns a new instance of PeeringGroupPeers.



3536
3537
3538
3539
3540
3541
3542
3543
# File 'lib/svc.rb', line 3536

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

Instance Method Details

#create(peering_group_peer, deadline: nil) ⇒ Object

Create links two peering groups.



3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
# File 'lib/svc.rb', line 3546

def create(
  peering_group_peer,
  deadline: nil
)
  req = V1::PeeringGroupPeerCreateRequest.new()

  req.peering_group_peer = Plumbing::convert_peering_group_peer_to_plumbing(peering_group_peer)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.create(req, metadata: @parent.("PeeringGroupPeers.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

  resp = PeeringGroupPeerCreateResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.peering_group_peer = Plumbing::convert_peering_group_peer_to_porcelain(plumbing_response.peering_group_peer)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

#delete(id, deadline: nil) ⇒ Object

Delete unlinks two peering groups.



3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
# File 'lib/svc.rb', line 3576

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

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

  resp = PeeringGroupPeerDeleteResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

#get(id, deadline: nil) ⇒ Object

Get reads the information of one peering group link.



3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
# File 'lib/svc.rb', line 3605

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

  req.id = (id)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.get(req, metadata: @parent.("PeeringGroupPeers.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

  resp = PeeringGroupPeerGetResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.peering_group_peer = Plumbing::convert_peering_group_peer_to_porcelain(plumbing_response.peering_group_peer)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

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

List gets a list of peering group links.



3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
# File 'lib/svc.rb', line 3639

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