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.
725 726 727 |
# File 'lib/safenet.rb', line 725 def initialize(client_obj) @client = client_obj end |
Instance Method Details
#append(handle_id, handle_data_id) ⇒ Object
835 836 837 838 839 840 841 842 843 844 845 846 847 |
# File 'lib/safenet.rb', line 835 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
729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 |
# File 'lib/safenet.rb', line 729 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
823 824 825 826 827 828 829 830 831 832 833 |
# File 'lib/safenet.rb', line 823 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
849 850 851 852 853 854 855 856 857 858 859 860 861 |
# File 'lib/safenet.rb', line 849 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
795 796 797 798 799 800 801 802 803 804 805 806 807 |
# File 'lib/safenet.rb', line 795 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
781 782 783 784 785 786 787 788 789 790 791 792 793 |
# File 'lib/safenet.rb', line 781 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
809 810 811 812 813 814 815 816 817 818 819 820 821 |
# File 'lib/safenet.rb', line 809 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
767 768 769 770 771 772 773 774 775 776 777 778 779 |
# File 'lib/safenet.rb', line 767 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
753 754 755 756 757 758 759 760 761 762 763 764 765 |
# File 'lib/safenet.rb', line 753 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 |