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.



3778
3779
3780
3781
3782
3783
3784
3785
# File 'lib/svc.rb', line 3778

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.



3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
# File 'lib/svc.rb', line 3788

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.



3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
# File 'lib/svc.rb', line 3818

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.



3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
# File 'lib/svc.rb', line 3847

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.



3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
# File 'lib/svc.rb', line 3881

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