Class: SDM::Policies
Overview
Policies are the collection of one or more statements that enforce fine-grained access control for the users of an organization.
See Policy.
Instance Method Summary collapse
-
#create(policy, deadline: nil) ⇒ Object
Create creates a new Policy.
-
#delete(id, deadline: nil) ⇒ Object
Delete removes a Policy by ID.
-
#get(id, deadline: nil) ⇒ Object
Get reads one Policy by ID.
-
#initialize(channel, parent) ⇒ Policies
constructor
A new instance of Policies.
-
#list(filter, *args, deadline: nil) ⇒ Object
List gets a list of Policy matching a given set of criteria.
-
#update(policy, deadline: nil) ⇒ Object
Update replaces all the fields of a Policy by ID.
Constructor Details
#initialize(channel, parent) ⇒ Policies
Returns a new instance of Policies.
3980 3981 3982 3983 3984 3985 3986 3987 |
# File 'lib/svc.rb', line 3980 def initialize(channel, parent) begin @stub = V1::Policies::Stub.new(nil, nil, channel_override: channel) rescue => exception raise Plumbing::convert_error_to_porcelain(exception) end @parent = parent end |
Instance Method Details
#create(policy, deadline: nil) ⇒ Object
Create creates a new Policy.
3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 |
# File 'lib/svc.rb', line 3990 def create( policy, deadline: nil ) req = V1::PolicyCreateRequest.new() req.policy = Plumbing::convert_policy_to_plumbing(policy) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.create(req, metadata: @parent.("Policies.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 = PolicyCreateResponse.new() resp.policy = Plumbing::convert_policy_to_porcelain(plumbing_response.policy) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |
#delete(id, deadline: nil) ⇒ Object
Delete removes a Policy by ID.
4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 |
# File 'lib/svc.rb', line 4019 def delete( id, deadline: nil ) req = V1::PolicyDeleteRequest.new() req.id = (id) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.delete(req, metadata: @parent.("Policies.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 = PolicyDeleteResponse.new() resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |
#get(id, deadline: nil) ⇒ Object
Get reads one Policy by ID.
4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 |
# File 'lib/svc.rb', line 4076 def get( id, deadline: nil ) req = V1::PolicyGetRequest.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.("Policies.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 = PolicyGetResponse.new() resp. = Plumbing::(plumbing_response.) resp.policy = Plumbing::convert_policy_to_porcelain(plumbing_response.policy) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |
#list(filter, *args, deadline: nil) ⇒ Object
List gets a list of Policy matching a given set of criteria
4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 |
# File 'lib/svc.rb', line 4110 def list( filter, *args, deadline: nil ) req = V1::PolicyListRequest.new() req. = V1::ListRequestMetadata.new() if @parent.page_limit > 0 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.("Policies.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.policies.each do |plumbing_item| g.yield Plumbing::convert_policy_to_porcelain(plumbing_item) end break if plumbing_response..next_cursor == "" req..cursor = plumbing_response..next_cursor end } resp end |
#update(policy, deadline: nil) ⇒ Object
Update replaces all the fields of a Policy by ID.
4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 |
# File 'lib/svc.rb', line 4047 def update( policy, deadline: nil ) req = V1::PolicyUpdateRequest.new() req.policy = Plumbing::convert_policy_to_plumbing(policy) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.update(req, metadata: @parent.("Policies.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 = PolicyUpdateResponse.new() resp.policy = Plumbing::convert_policy_to_porcelain(plumbing_response.policy) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |