Class: SDM::Accounts
- Inherits:
-
Object
- Object
- SDM::Accounts
- Defined in:
- lib/svc.rb
Overview
Accounts are users that have access to strongDM. There are two types of accounts:
-
Users: humans who are authenticated through username and password or SSO.
-
**Service Accounts:** machines that are authenticated using a service token.
Instance Method Summary collapse
-
#create(account, deadline: nil) ⇒ Object
Create registers a new Account.
-
#delete(id, deadline: nil) ⇒ Object
Delete removes a Account by ID.
-
#get(id, deadline: nil) ⇒ Object
Get reads one Account by ID.
-
#initialize(host, insecure, parent) ⇒ Accounts
constructor
A new instance of Accounts.
-
#list(filter, *args, deadline: nil) ⇒ Object
List gets a list of Accounts matching a given set of criteria.
-
#update(account, deadline: nil) ⇒ Object
Update patches a Account by ID.
Constructor Details
#initialize(host, insecure, parent) ⇒ Accounts
Returns a new instance of Accounts.
317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/svc.rb', line 317 def initialize(host, insecure, parent) begin if insecure @stub = V1::Accounts::Stub.new(host, :this_channel_is_insecure) else cred = GRPC::Core::ChannelCredentials.new() @stub = V1::Accounts::Stub.new(host, cred) end rescue => exception raise Plumbing::convert_error_to_porcelain(exception) end @parent = parent end |
Instance Method Details
#create(account, deadline: nil) ⇒ Object
Create registers a new Account.
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
# File 'lib/svc.rb', line 332 def create( account, deadline: nil ) req = V1::AccountCreateRequest.new() req.account = Plumbing::convert_account_to_plumbing(account) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.create(req, metadata: @parent.("Accounts.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 = AccountCreateResponse.new() resp. = Plumbing::(plumbing_response.) resp.account = Plumbing::convert_account_to_porcelain(plumbing_response.account) resp.token = (plumbing_response.token) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |
#delete(id, deadline: nil) ⇒ Object
Delete removes a Account by ID.
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 |
# File 'lib/svc.rb', line 423 def delete( id, deadline: nil ) req = V1::AccountDeleteRequest.new() req.id = (id) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.delete(req, metadata: @parent.("Accounts.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 = AccountDeleteResponse.new() resp. = Plumbing::(plumbing_response.) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |
#get(id, deadline: nil) ⇒ Object
Get reads one Account by ID.
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
# File 'lib/svc.rb', line 363 def get( id, deadline: nil ) req = V1::AccountGetRequest.new() req.id = (id) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.get(req, metadata: @parent.("Accounts.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 = AccountGetResponse.new() resp. = Plumbing::(plumbing_response.) resp.account = Plumbing::convert_account_to_porcelain(plumbing_response.account) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |
#list(filter, *args, deadline: nil) ⇒ Object
List gets a list of Accounts matching a given set of criteria.
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
# File 'lib/svc.rb', line 452 def list( filter, *args, deadline: nil ) req = V1::AccountListRequest.new() req. = V1::ListRequestMetadata.new() page_size_option = @parent.["PageSize"] if page_size_option.is_a? Integer req..limit = page_size_option 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.("Accounts.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.accounts.each do |plumbing_item| g.yield Plumbing::convert_account_to_porcelain(plumbing_item) end break if plumbing_response..next_cursor == "" req..cursor = plumbing_response..next_cursor end } resp end |
#update(account, deadline: nil) ⇒ Object
Update patches a Account by ID.
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
# File 'lib/svc.rb', line 393 def update( account, deadline: nil ) req = V1::AccountUpdateRequest.new() req.account = Plumbing::convert_account_to_plumbing(account) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.update(req, metadata: @parent.("Accounts.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 = AccountUpdateResponse.new() resp. = Plumbing::(plumbing_response.) resp.account = Plumbing::convert_account_to_porcelain(plumbing_response.account) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |