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.
6027 6028 6029 6030 6031 6032 6033 6034 |
# File 'lib/svc.rb', line 6027 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.
6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 |
# File 'lib/svc.rb', line 6037 def create( policy, deadline: nil ) req = V1::PolicyCreateRequest.new() req.policy = Plumbing::convert_policy_to_plumbing(policy) # Execute before interceptor hooks req = @parent.interceptor.execute_before("Policies.Create", self, req) 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, deadline)) tries + +sleep(@parent.exponentialBackoff(tries, deadline)) next end raise Plumbing::convert_error_to_porcelain(exception) end break end # Execute after interceptor hooks plumbing_response = @parent.interceptor.execute_after("Policies.Create", self, req, plumbing_response) 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.
6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 |
# File 'lib/svc.rb', line 6071 def delete( id, deadline: nil ) req = V1::PolicyDeleteRequest.new() req.id = (id) # Execute before interceptor hooks req = @parent.interceptor.execute_before("Policies.Delete", self, req) 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, deadline)) tries + +sleep(@parent.exponentialBackoff(tries, deadline)) next end raise Plumbing::convert_error_to_porcelain(exception) end break end # Execute after interceptor hooks plumbing_response = @parent.interceptor.execute_after("Policies.Delete", self, req, plumbing_response) resp = PolicyDeleteResponse.new() resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |
#get(id, deadline: nil) ⇒ Object
Get reads one Policy by ID.
6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 |
# File 'lib/svc.rb', line 6138 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) # Execute before interceptor hooks req = @parent.interceptor.execute_before("Policies.Get", self, req) 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, deadline)) tries + +sleep(@parent.exponentialBackoff(tries, deadline)) next end raise Plumbing::convert_error_to_porcelain(exception) end break end # Execute after interceptor hooks plumbing_response = @parent.interceptor.execute_after("Policies.Get", self, req, plumbing_response) 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
6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 |
# File 'lib/svc.rb', line 6177 def list( filter, *args, deadline: nil ) req = V1::PolicyListRequest.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.("Policies.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.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.
6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 |
# File 'lib/svc.rb', line 6104 def update( policy, deadline: nil ) req = V1::PolicyUpdateRequest.new() req.policy = Plumbing::convert_policy_to_plumbing(policy) # Execute before interceptor hooks req = @parent.interceptor.execute_before("Policies.Update", self, req) 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, deadline)) tries + +sleep(@parent.exponentialBackoff(tries, deadline)) next end raise Plumbing::convert_error_to_porcelain(exception) end break end # Execute after interceptor hooks plumbing_response = @parent.interceptor.execute_after("Policies.Update", self, req, plumbing_response) resp = PolicyUpdateResponse.new() resp.policy = Plumbing::convert_policy_to_porcelain(plumbing_response.policy) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |