GET Applications – Client examples

GET all Applications

/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * GetAll  Applications client demonstrates listing all your applications from Bluedot backend
 * using 'request' node module.
 */
var request = require('request');
var bdCustomerApiKey = "86577370-7b91-11e4-bcb7-a0481cdc3311"; //This key is generated by Bluedot Point Access UI when your account is created
var options = {
    uri: 'https://api.bluedotinnovation.com/1/applications?customerApiKey=' + bdCustomerApiKey,
    method: 'GET'
};
request ( options,
    function (error, response, body) {
        if (error) {
            console.log(error);
        }
        var result = response.body;
        if( typeof result !== 'string' ) {
            console.log("Error in response");
            return;
            result = JSON.stringify(result)
        }
        console.log(result);
    }
);

GET a specific Application

/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Get Application client demonstrates an application for a given apiKey from Bluedot backend
 * using 'request' node module.
 */
var request = require('request');
var bdCustomerApiKey = "86577370-7b91-11e4-bcb7-a0481cdc3311"; //This key is generated by Bluedot Point Access UI when your account is created
var bdApplicationApiKey = "a4e5b264-d231-436b-b30e-4065bd517f02"; //This apiKey is generated when you create an application
var options = {
    uri: 'https://api.bluedotinnovation.com/1/applications?customerApiKey=' + bdCustomerApiKey + '&apiKey=' + bdApplicationApiKey,
    method: 'GET'
};
request ( options,
    function (error, response, body) {
        if (error) {
            console.log(error);
        }
        var result = response.body;
        if( typeof result !== 'string' ) {
            console.log("Error in response");
            return;
            result = JSON.stringify(result)
        }
        console.log(result);
    }
);

GET all Applications

package com.bluedotinnovation.application;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.bluedotinnovation.common.BDCommon;
/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Get Applications client demonstrates listing all your applications from Bluedot backend using Apache HTTP client and JSON Simple libraries.
 */
public class GetAllApplications extends BDCommon {
    public static void main(String[] args) throws IOException, KeyManagementException, NoSuchAlgorithmException, ParseException {
         
        String bdCustomerApiKey     = "7cd1ea80-d40e-11e4-84cb-b8ca3a6b879d"; //This key is generated by Bluedot Point Access UI when your account is created
        String bdRestUrl            = "https://api.bluedotinnovation.com/1/applications?customerApiKey=" + bdCustomerApiKey;
        CloseableHttpClient httpRestClient = HttpClients.custom().setSSLSocketFactory(getSSLContextFactory()).build();
        HttpGet request       = new HttpGet(bdRestUrl);
        HttpResponse response = httpRestClient.execute(request);
        BufferedReader rd     = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
        JSONParser parser          = new JSONParser();
        String bdApplicationJSON = "";
        while ((bdApplicationJSON = rd.readLine()) != null) {
            Object object = parser.parse(bdApplicationJSON);
            JSONArray bdApplicationJsonArray = (JSONArray) object;
            for (Object applicationObject : bdApplicationJsonArray){
                JSONObject jsonObject =  (JSONObject) applicationObject;
                System.out.println("App name : " + jsonObject.get("name"));
                System.out.println("App id: " + jsonObject.get("_id"));
                System.out.println("App apiKey: " + jsonObject.get("apiKey"));
                System.out.println("App packageName: " + jsonObject.get("packageName"));
                System.out.println("App Ruleset download interval: " + jsonObject.get("nextRuleUpdateIntervalFormatted"));
                System.out.println("---------\n");
            }
        }
    }
}

GET a specific Application

package com.bluedotinnovation.application;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import com.bluedotinnovation.common.BDCommon;
/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Get Application client demonstrates listing an application for a given apiKey from Bluedot backend using Apache HTTP client and JSON Simple libraries.
 */
public class GetApplication extends BDCommon {
    public static void main(String[] args) throws IOException, KeyManagementException, NoSuchAlgorithmException {
         
        String bdApplicationApiKey     = "a4e5b264-d231-436b-b30e-4065bd517f02"; //This apiKey is generated when you create an application and which has to be retrieved.
        String bdCustomerApiKey = "86577370-7b91-11e4-bcb7-a0481cdc3311"; //This key is generated by Bluedot Point Access UI when your account is created
        String bdRestUrl        = "https://api.bluedotinnovation.com/1/applications?customerApiKey=" +bdCustomerApiKey + "&apiKey=" + bdApplicationApiKey;
        CloseableHttpClient httpRestClient = HttpClients.custom().setSSLSocketFactory(getSSLContextFactory()).build();
        HttpGet request       = new HttpGet(bdRestUrl);
        HttpResponse response = httpRestClient.execute(request);
        BufferedReader rd     = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
        String line           = "";
        while ( (line = rd.readLine()) != null ) {
             System.out.println(line);
        }
    }
}

GET all Applications

using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using System.Web.Script.Serialization;
/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Get All Applications client demonstrates listing for all applications for a given customer.
 */
namespace BluedotPublicApiClient.applicationclient
{
    public class GetAllApplications
    {
        private static String customerApiKey = "ca4c8d11-6942-11e4-ba4b-a0481cdc3311"; //This key is generated by Bluedot Point Access UI when your account is created
        private static String bdRestUrl      = "https://api.bluedotinnovation.com/1/applications?customerApiKey=" + customerApiKey;
        public void getAllApplicationsForCustomer()
        {
            HttpClient httpRestClient = new HttpClient();
            HttpResponseMessage serverResponse = httpRestClient.GetAsync(new Uri(bdRestUrl)).Result;
            if (serverResponse.IsSuccessStatusCode)
            {
                var result = serverResponse.Content.ReadAsStringAsync().Result;
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                dynamic applications = serializer.Deserialize(result, typeof(object)); // Result is an array of json
                foreach (var application in applications)
                {
                    Console.WriteLine("_id : {0} ", application["_id"]);
                    Console.WriteLine("apiKey : {0} ", application["apiKey"]);
                    Console.WriteLine("name : {0} ", application["name"]);
                    Console.WriteLine("---------\n");
                }
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)serverResponse.StatusCode, serverResponse.Content.ReadAsStringAsync().Result);
            }
        }
    }
}

GET a specific Application

using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using System.Web.Script.Serialization;
/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Get Application client demonstrates listing an application for a given apiKey from Bluedot backend.
 */
namespace BluedotPublicApiClient.applicationclient
{
    public class GetApplication
    {
        private static String apiKey         = "b817bb5d-4b58-4f41-be5f-528fd4c7c95c"; //This apiKey is generated when you create an application
        private static String customerApiKey = "ca4c8d11-6942-11e4-ba4b-a0481cdc3311"; //This key is generated by Bluedot Point Access UI when your account is created
        private static String bdRestUrl      = "https://api.bluedotinnovation.com/1/applications?customerApiKey=" + customerApiKey + "&apiKey=" + apiKey;
        public void getApplications()
        {
            HttpClient httpRestClient = new HttpClient();
            HttpResponseMessage serverResponse = httpRestClient.GetAsync(new Uri(bdRestUrl)).Result;
            if (serverResponse.IsSuccessStatusCode)
            {
                var result = serverResponse.Content.ReadAsStringAsync().Result;
                Console.WriteLine("{0}", result);
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)serverResponse.StatusCode, serverResponse.Content.ReadAsStringAsync().Result);
            }
        }
    }
}
Created by Bluedot DevOps on March 3, 2018

Start the discussion