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.



3275
3276
3277
3278
3279
3280
3281
3282
# File 'lib/svc.rb', line 3275

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



3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
# File 'lib/svc.rb', line 3285

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))
        tries + +@parent.jitterSleep(tries)
        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



3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
# File 'lib/svc.rb', line 3315

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))
        tries + +@parent.jitterSleep(tries)
        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.



3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
# File 'lib/svc.rb', line 3344

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))
        tries + +@parent.jitterSleep(tries)
        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.



3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
# File 'lib/svc.rb', line 3378

def list(
  filter,
  *args,
  deadline: nil
)
  req = V1::PeeringGroupResourceListRequest.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.("PeeringGroupResources.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_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