Class: SDM::Groups
Overview
A Group is a set of principals.
See Group.
Instance Method Summary collapse
-
#create(group, deadline: nil) ⇒ Object
Create registers a new Group.
- #create_from_roles(role_ids, commit, deadline: nil) ⇒ Object
-
#delete(id, deadline: nil) ⇒ Object
Delete removes a Group by ID.
-
#get(id, deadline: nil) ⇒ Object
Get reads one Group by ID.
-
#initialize(channel, parent) ⇒ Groups
constructor
A new instance of Groups.
-
#list(filter, *args, deadline: nil) ⇒ Object
List gets a list of Groups matching a given set of criteria.
-
#update(group, deadline: nil) ⇒ Object
Update replaces all the fields of a Group by ID.
Constructor Details
#initialize(channel, parent) ⇒ Groups
Returns a new instance of Groups.
2567 2568 2569 2570 2571 2572 2573 2574 |
# File 'lib/svc.rb', line 2567 def initialize(channel, parent) begin @stub = V1::Groups::Stub.new(nil, nil, channel_override: channel) rescue => exception raise Plumbing::convert_error_to_porcelain(exception) end @parent = parent end |
Instance Method Details
#create(group, deadline: nil) ⇒ Object
Create registers a new Group.
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 |
# File 'lib/svc.rb', line 2577 def create( group, deadline: nil ) req = V1::GroupCreateRequest.new() req.group = Plumbing::convert_group_to_plumbing(group) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.create(req, metadata: @parent.("Groups.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 = GroupCreateResponse.new() resp.group = Plumbing::convert_group_to_porcelain(plumbing_response.group) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |
#create_from_roles(role_ids, commit, deadline: nil) ⇒ Object
2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 |
# File 'lib/svc.rb', line 2605 def create_from_roles( role_ids, commit, deadline: nil ) req = V1::GroupCreateFromRolesRequest.new() req.role_ids += (role_ids) req.commit = (commit) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.create_from_roles(req, metadata: @parent.("Groups.CreateFromRoles", 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 = GroupCreateFromRolesResponse.new() resp.group_from_role = Plumbing::convert_repeated_group_from_role_to_porcelain(plumbing_response.group_from_role) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |
#delete(id, deadline: nil) ⇒ Object
Delete removes a Group by ID.
2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 |
# File 'lib/svc.rb', line 2699 def delete( id, deadline: nil ) req = V1::GroupDeleteRequest.new() req.id = (id) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.delete(req, metadata: @parent.("Groups.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 = GroupDeleteResponse.new() resp. = Plumbing::(plumbing_response.) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |
#get(id, deadline: nil) ⇒ Object
Get reads one Group by ID.
2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 |
# File 'lib/svc.rb', line 2636 def get( id, deadline: nil ) req = V1::GroupGetRequest.new() if not @parent.snapshot_time.nil? req. = V1::GetRequestMetadata.new() req..snapshot_at = @parent.snapshot_time end req.id = (id) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.get(req, metadata: @parent.("Groups.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 = GroupGetResponse.new() resp.group = Plumbing::convert_group_to_porcelain(plumbing_response.group) resp. = Plumbing::(plumbing_response.) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |
#list(filter, *args, deadline: nil) ⇒ Object
List gets a list of Groups matching a given set of criteria.
2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 |
# File 'lib/svc.rb', line 2728 def list( filter, *args, deadline: nil ) req = V1::GroupListRequest.new() req. = V1::ListRequestMetadata.new() if not @parent.page_limit.nil? req..limit = @parent.page_limit end if not @parent.snapshot_time.nil? req..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.("Groups.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.groups.each do |plumbing_item| g.yield Plumbing::convert_group_to_porcelain(plumbing_item) end break if plumbing_response..next_cursor == "" req..cursor = plumbing_response..next_cursor end } resp end |
#update(group, deadline: nil) ⇒ Object
Update replaces all the fields of a Group by ID.
2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 |
# File 'lib/svc.rb', line 2670 def update( group, deadline: nil ) req = V1::GroupUpdateRequest.new() req.group = Plumbing::convert_group_to_plumbing(group) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.update(req, metadata: @parent.("Groups.Update", 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 = GroupUpdateResponse.new() resp.group = Plumbing::convert_group_to_porcelain(plumbing_response.group) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |