DELETE Zone – Client examples

/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Delete Zone client demonstrates deleting a Zone using 'request' node module
 */
var request = require('request');
  
var bdCustomerApiKey = "6ab02370-97c4-11e4-b3f3-00155d53317c"; //This key is generated by Bluedot Point Access UI when your account is created
var bdApplicationApiKey    = "d66d4f5d-7c09-4bd1-8549-48893f121"; //This apiKey is generated when you create an application
var bdZoneId = "e8ed5a00-705c-409a-8c1e-9e4f7c70bbd6"; //This is the id of the Zone being deleted. This can be fetched by calling GET Zones API
  
var options = {
    uri: "https://api.bluedotinnovation.com/1/zones?customerApiKey="+ bdCustomerApiKey + "&apiKey=" + bdApplicationApiKey + "&zoneId=" + bdZoneId,
    method: "DELETE"
};
  
request ( options,
    function (error, response, body) {
        if (error) {
            console.log(error);
        }
        console.log(JSON.stringify(response.body));
    }
);
package com.bluedotinnovation.zone;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import com.bluedotinnovation.common.BDCommon;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Delete Zone client demonstrates deleting a Zone using Apache HTTP client libraries
 */
public class DeleteZone extends BDCommon {
     
    public static void main(String[] args) throws ParseException, IOException, KeyManagementException, NoSuchAlgorithmException {
        String bdCustomerApiKey     = "0cbfd210-9544-11e4-b884-402cf464abb8"; //This key is generated by Bluedot Point Access UI when your account is created
        String bdApplicationApiKey  = "d3161e80-38d1-11e4-b039-bc305bf60831"; //This apiKey is generated when you create an application
        String bdZoneId             = "d6c3b688-cf2e-4aac-b76b-b29f371f448e"; //This is the ID of the Zone being deleted. This can be fetched by calling the GET Zones API.
        String bdRestUrl            = "https://api.bluedotinnovation.com/1/zones?customerApiKey="+bdCustomerApiKey+"&apiKey="+bdApplicationApiKey+"&zoneId=" + bdZoneId;
         
        CloseableHttpClient httpRestClient = HttpClients.custom().setSSLSocketFactory(getSSLContextFactory()).build();
        HttpDelete request    = new HttpDelete(bdRestUrl);
        HttpResponse response = httpRestClient.execute(request);
        JSONParser parser     = new JSONParser();
        if (response.getStatusLine().getStatusCode() == 200) {
            System.out.println("Zone has been deleted successfully");
            InputStream inputStream = response.getEntity().getContent();
            byte[] bytes            = readStream(inputStream);
            String resultString     = new String(bytes); //json result
            JSONObject jsonResult   = (JSONObject)  parser.parse(resultString);
            System.out.println(jsonResult);
        } else {
            InputStream inputStream = response.getEntity().getContent();
            byte[] bytes            = readStream(inputStream);
            String resultString     = new String(bytes); //json error result
            System.out.println(resultString);
        }
    }
}
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.Web.Script.Serialization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
/**
* @author Bluedot Innovation
* Copyright (c) 2016 Bluedot Innovation. All rights reserved.
* Delete Zone client demonstrates deleting an Zone using the id provided, through http web api library
*/
namespace BluedotPublicApiClient.zoneclient
{
    class DeleteZone
    {
        public void delete()
        {
            String bdCustomerApiKey     = "76e1ae30-c616-11e5-a7c0-b8ca3a6b879d"; //This key is generated by Bluedot Point Access UI when your account is created
            String bdApplicationApiKey  = "dee11930-ebff-11e5-8e27-bc305bf60831"; //This apiKey is generated when you create an application
            String bdZoneId             = "720f2f5d-7057-4668-a546-542abc4f2128"; //This can be extracted via the GET Zones api or the Web Dashboard
            String bdRestBaseUrl        = "https://api.bluedotinnovation.com/1/zones?";
            String bdRestUrl        = bdRestBaseUrl + "customerApiKey=" + bdCustomerApiKey + "&apiKey=" + bdApplicationApiKey + "&zoneId=" + bdZoneId;
            WebRequestHandler handler = new WebRequestHandler();
            X509Certificate2 certificate = new X509Certificate2();
            handler.ClientCertificates.Add(certificate);
            HttpClient httpRestClient = new HttpClient(handler);
            //specify to use TLS 1.2 as default connection
            System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
            HttpResponseMessage serverResponse = httpRestClient.DeleteAsync(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 5, 2018

Start the discussion