Class: SafeNet::AD
- Inherits:
-
Object
- Object
- SafeNet::AD
- Defined in:
- lib/safenet.rb
Instance Method Summary collapse
- #append(handle_id, handle_data_id) ⇒ Object
- #create(name, is_private = false, filter_type = 'BLACK_LIST', filter_key = nil) ⇒ Object
- #drop_handle(handle_id) ⇒ Object
- #get_data_id_at_index(handle_id, index) ⇒ Object
- #get_data_id_handle(handle_id) ⇒ Object
- #get_handle(data_id_handle) ⇒ Object
- #get_metadata(handle_id) ⇒ Object
-
#initialize(client_obj) ⇒ AD
constructor
A new instance of AD.
- #post(handle_id) ⇒ Object
- #put(handle_id) ⇒ Object
Constructor Details
#initialize(client_obj) ⇒ AD
Returns a new instance of AD.
721 722 723 |
# File 'lib/safenet.rb', line 721 def initialize(client_obj) @client = client_obj end |
Instance Method Details
#append(handle_id, handle_data_id) ⇒ Object
831 832 833 834 835 836 837 838 839 840 841 842 843 |
# File 'lib/safenet.rb', line 831 def append(handle_id, handle_data_id) # Entry point url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/appendable-data/#{handle_id}/#{handle_data_id}" # API call uri = URI(url) http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Put.new(uri.path, { 'Authorization' => "Bearer #{@client.key_helper.get_valid_token()}" }) res = http.request(req) res.code == "200" ? true : JSON.parse(res.body) end |
#create(name, is_private = false, filter_type = 'BLACK_LIST', filter_key = nil) ⇒ Object
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/safenet.rb', line 725 def create(name, is_private = false, filter_type = 'BLACK_LIST', filter_key = nil) # Entry point url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/appendable-data" # Payload payload = { name: name, isPrivate: is_private, filterType: filter_type, filterKey: filter_key } # API call uri = URI(url) http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Post.new(uri.path, { 'Authorization' => "Bearer #{@client.key_helper.get_valid_token()}", 'Content-Type' => 'application/json' }) req.body = payload.to_json res = http.request(req) res.code == "200" ? JSON.parse(res.body)['handleId'] : JSON.parse(res.body) end |
#drop_handle(handle_id) ⇒ Object
819 820 821 822 823 824 825 826 827 828 829 |
# File 'lib/safenet.rb', line 819 def drop_handle(handle_id) # entry point url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/appendable-data/handle/#{handle_id}" # api call uri = URI(url) http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Delete.new(uri.path) res = http.request(req) res.code == "200" ? true : JSON.parse(res.body) end |
#get_data_id_at_index(handle_id, index) ⇒ Object
845 846 847 848 849 850 851 852 853 854 855 856 857 |
# File 'lib/safenet.rb', line 845 def get_data_id_at_index(handle_id, index) # Entry point url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/appendable-data/#{handle_id}/#{index}" # API call uri = URI(url) http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Get.new(uri.path, { 'Authorization' => "Bearer #{@client.key_helper.get_valid_token()}" }) res = http.request(req) res.code == "200" ? JSON.parse(res.body)["handleId"] : JSON.parse(res.body) end |
#get_data_id_handle(handle_id) ⇒ Object
791 792 793 794 795 796 797 798 799 800 801 802 803 |
# File 'lib/safenet.rb', line 791 def get_data_id_handle(handle_id) # entry point url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/appendable-data/data-id/#{handle_id}" # api call uri = URI(url) http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Get.new(uri.path, { 'Authorization' => "Bearer #{@client.key_helper.get_token()}" }) res = http.request(req) res.code == "200" ? JSON.parse(res.body)['handleId'] : JSON.parse(res.body) end |
#get_handle(data_id_handle) ⇒ Object
777 778 779 780 781 782 783 784 785 786 787 788 789 |
# File 'lib/safenet.rb', line 777 def get_handle(data_id_handle) # entry point url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/appendable-data/handle/#{data_id_handle}" # api call uri = URI(url) http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Get.new(uri.path, { 'Authorization' => "Bearer #{@client.key_helper.get_token()}" }) res = http.request(req) JSON.parse(res.body) end |
#get_metadata(handle_id) ⇒ Object
805 806 807 808 809 810 811 812 813 814 815 816 817 |
# File 'lib/safenet.rb', line 805 def (handle_id) # entry point url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/appendable-data/metadata/#{handle_id}" # api call uri = URI(url) http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Get.new(uri.path, { 'Authorization' => "Bearer #{@client.key_helper.get_token()}" }) res = http.request(req) JSON.parse(res.body) end |
#post(handle_id) ⇒ Object
763 764 765 766 767 768 769 770 771 772 773 774 775 |
# File 'lib/safenet.rb', line 763 def post(handle_id) # Entry point url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/appendable-data/#{handle_id}" # API call uri = URI(url) http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Post.new(uri.path, { 'Authorization' => "Bearer #{@client.key_helper.get_valid_token()}" }) res = http.request(req) res.code == "200" ? true : JSON.parse(res.body) end |
#put(handle_id) ⇒ Object
749 750 751 752 753 754 755 756 757 758 759 760 761 |
# File 'lib/safenet.rb', line 749 def put(handle_id) # Entry point url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/appendable-data/#{handle_id}" # API call uri = URI(url) http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Put.new(uri.path, { 'Authorization' => "Bearer #{@client.key_helper.get_valid_token()}" }) res = http.request(req) res.code == "200" ? true : JSON.parse(res.body) end |