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.
2781 2782 2783 2784 2785 2786 2787 2788 |
# File 'lib/svc.rb', line 2781 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.
2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 |
# File 'lib/svc.rb', line 2791 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
2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 |
# File 'lib/svc.rb', line 2819 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.
2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 |
# File 'lib/svc.rb', line 2913 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.
2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 |
# File 'lib/svc.rb', line 2850 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.
2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 |
# File 'lib/svc.rb', line 2942 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.
2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 |
# File 'lib/svc.rb', line 2884 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 |