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.
4223 4224 4225 4226 4227 4228 4229 4230 |
# File 'lib/svc.rb', line 4223 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.
4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 |
# File 'lib/svc.rb', line 4233 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.
4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 |
# File 'lib/svc.rb', line 4262 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.
4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 |
# File 'lib/svc.rb', line 4319 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
4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 |
# File 'lib/svc.rb', line 4353 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.
4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 |
# File 'lib/svc.rb', line 4290 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 |