Class: SDM::IdentitySets

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

Overview

A IdentitySet is a named grouping of Identity Aliases for Accounts. An Account's relationship to a IdentitySet is defined via IdentityAlias objects.

See IdentitySet.

Instance Method Summary collapse

Constructor Details

#initialize(channel, parent) ⇒ IdentitySets

Returns a new instance of IdentitySets.



2441
2442
2443
2444
2445
2446
2447
2448
# File 'lib/svc.rb', line 2441

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

Instance Method Details

#create(identity_set, deadline: nil) ⇒ Object

Create registers a new IdentitySet.



2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
# File 'lib/svc.rb', line 2451

def create(
  identity_set,
  deadline: nil
)
  req = V1::IdentitySetCreateRequest.new()

  req.identity_set = Plumbing::convert_identity_set_to_plumbing(identity_set)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.create(req, metadata: @parent.("IdentitySets.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 = IdentitySetCreateResponse.new()
  resp.identity_set = Plumbing::convert_identity_set_to_porcelain(plumbing_response.identity_set)
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

#delete(id, deadline: nil) ⇒ Object

Delete removes a IdentitySet by ID.



2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
# File 'lib/svc.rb', line 2545

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

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



2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
# File 'lib/svc.rb', line 2481

def get(
  id,
  deadline: nil
)
  req = V1::IdentitySetGetRequest.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.("IdentitySets.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 = IdentitySetGetResponse.new()
  resp.identity_set = Plumbing::convert_identity_set_to_porcelain(plumbing_response.identity_set)
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

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

List gets a list of IdentitySets matching a given set of criteria.



2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
# File 'lib/svc.rb', line 2574

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

#update(identity_set, deadline: nil) ⇒ Object

Update replaces all the fields of a IdentitySet by ID.



2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
# File 'lib/svc.rb', line 2515

def update(
  identity_set,
  deadline: nil
)
  req = V1::IdentitySetUpdateRequest.new()

  req.identity_set = Plumbing::convert_identity_set_to_plumbing(identity_set)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.update(req, metadata: @parent.("IdentitySets.Update", 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 = IdentitySetUpdateResponse.new()
  resp.identity_set = Plumbing::convert_identity_set_to_porcelain(plumbing_response.identity_set)
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end