Class: SDM::PeeringGroups

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

Overview

PeeringGroups provides the building blocks necessary to obtain explicit network topology and routing.

See PeeringGroup.

Instance Method Summary collapse

Constructor Details

#initialize(channel, parent) ⇒ PeeringGroups

Returns a new instance of PeeringGroups.



3423
3424
3425
3426
3427
3428
3429
3430
# File 'lib/svc.rb', line 3423

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

Create registers a new PeeringGroup.



3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
# File 'lib/svc.rb', line 3433

def create(
  peering_group,
  deadline: nil
)
  req = V1::PeeringGroupCreateRequest.new()

  req.peering_group = Plumbing::convert_peering_group_to_plumbing(peering_group)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.create(req, metadata: @parent.("PeeringGroups.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 = PeeringGroupCreateResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.peering_group = Plumbing::convert_peering_group_to_porcelain(plumbing_response.peering_group)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

#delete(id, deadline: nil) ⇒ Object

Delete removes a PeeringGroup by ID.



3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
# File 'lib/svc.rb', line 3463

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

  req.id = (id)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.delete(req, metadata: @parent.("PeeringGroups.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 = PeeringGroupDeleteResponse.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 PeeringGroup by ID. It will load all its dependencies.



3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
# File 'lib/svc.rb', line 3492

def get(
  id,
  deadline: nil
)
  req = V1::PeeringGroupGetRequest.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.("PeeringGroups.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 = PeeringGroupGetResponse.new()
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.peering_group = Plumbing::convert_peering_group_to_porcelain(plumbing_response.peering_group)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

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

List gets a list of Peering Groups.



3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
# File 'lib/svc.rb', line 3526

def list(
  filter,
  *args,
  deadline: nil
)
  req = V1::PeeringGroupListRequest.new()
  req.meta = V1::ListRequestMetadata.new()
  if @parent.page_limit > 0
    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.("PeeringGroups.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.peering_groups.each do |plumbing_item|
        g.yield Plumbing::convert_peering_group_to_porcelain(plumbing_item)
      end
      break if plumbing_response.meta.next_cursor == ""
      req.meta.cursor = plumbing_response.meta.next_cursor
    end
  }
  resp
end