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.
5243 5244 5245 5246 5247 5248 5249 5250 |
# File 'lib/svc.rb', line 5243 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.
5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 |
# File 'lib/svc.rb', line 5253 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, deadline)) tries + +sleep(@parent.exponentialBackoff(tries, deadline)) 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.
5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 |
# File 'lib/svc.rb', line 5282 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, deadline)) tries + +sleep(@parent.exponentialBackoff(tries, deadline)) 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.
5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 |
# File 'lib/svc.rb', line 5339 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, deadline)) tries + +sleep(@parent.exponentialBackoff(tries, deadline)) 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
5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 |
# File 'lib/svc.rb', line 5373 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.
5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 |
# File 'lib/svc.rb', line 5310 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, deadline)) tries + +sleep(@parent.exponentialBackoff(tries, deadline)) 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 |