Class: SDM::PeeringGroupResources

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

Overview

PeeringGroupResources provides the building blocks necessary to obtain attach a resource to a peering group.

See PeeringGroupResource.

Instance Method Summary collapse

Constructor Details

#initialize(channel, parent) ⇒ PeeringGroupResources

Returns a new instance of PeeringGroupResources.



3926
3927
3928
3929
3930
3931
3932
3933
# File 'lib/svc.rb', line 3926

def initialize(channel, parent)
  begin
    @stub = V1::PeeringGroupResources::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_resource, deadline: nil) ⇒ Object

Create attaches a Resource to a PeeringGroup



3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
# File 'lib/svc.rb', line 3936

def create(
  peering_group_resource,
  deadline: nil
)
  req = V1::PeeringGroupResourceCreateRequest.new()

  req.peering_group_resource = Plumbing::convert_peering_group_resource_to_plumbing(peering_group_resource)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.create(req, metadata: @parent.("PeeringGroupResources.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 = PeeringGroupResourceCreateResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.peering_group_resource = Plumbing::convert_peering_group_resource_to_porcelain(plumbing_response.peering_group_resource)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

#delete(id, deadline: nil) ⇒ Object

Delete detaches a Resource to a PeeringGroup



3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
# File 'lib/svc.rb', line 3966

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

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



3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
# File 'lib/svc.rb', line 3995

def get(
  id,
  deadline: nil
)
  req = V1::PeeringGroupResourceGetRequest.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.("PeeringGroupResources.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 = PeeringGroupResourceGetResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.peering_group_resource = Plumbing::convert_peering_group_resource_to_porcelain(plumbing_response.peering_group_resource)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

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

List gets a list of peering group resource attachments.



4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
# File 'lib/svc.rb', line 4029

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