Class: SDM::Accounts
Overview
Instance Method Summary collapse
-
#create(account, deadline: nil) ⇒ Object
Create registers a new Account.
-
#delete(id, deadline: nil) ⇒ Object
Delete removes an Account by ID.
-
#get(id, deadline: nil) ⇒ Object
Get reads one Account by ID.
-
#initialize(channel, 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 replaces all the fields of an Account by ID.
Constructor Details
#initialize(channel, parent) ⇒ Accounts
Returns a new instance of Accounts.
675 676 677 678 679 680 681 682 |
# File 'lib/svc.rb', line 675 def initialize(channel, parent) begin @stub = V1::Accounts::Stub.new(nil, nil, channel_override: channel) 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.
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 |
# File 'lib/svc.rb', line 685 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.account = Plumbing::convert_account_to_porcelain(plumbing_response.account) resp. = Plumbing::(plumbing_response.) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp.token = (plumbing_response.token) resp end |
#delete(id, deadline: nil) ⇒ Object
Delete removes an Account by ID.
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 |
# File 'lib/svc.rb', line 780 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.
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 |
# File 'lib/svc.rb', line 716 def get( id, deadline: nil ) req = V1::AccountGetRequest.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.("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.account = Plumbing::convert_account_to_porcelain(plumbing_response.account) resp. = Plumbing::(plumbing_response.) 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.
809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 |
# File 'lib/svc.rb', line 809 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 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.("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 replaces all the fields of an Account by ID.
750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 |
# File 'lib/svc.rb', line 750 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.account = Plumbing::convert_account_to_porcelain(plumbing_response.account) resp. = Plumbing::(plumbing_response.) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |