DELETE Action – Client examples

/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Delete Action client demonstrates deleting an action from an existing zone
 * using the '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 = "4f134aaa-3382-49bb-b7c7-a0bf72e56238";  //This is the ID of the zone being updated. This can be fetched by calling GET Zones API.
var bdActionId = "86bd13a8-d7da-4c92-afba-d000dc04b422"; //This is the ID of the action being deleted. This can be fetched by calling GET Zones API.
  
var options = {
    uri: "https://api.bluedotinnovation.com/1/actions?customerApiKey=" + bdCustomerApiKey + "&apiKey=" + bdApplicationApiKey +
        "&zoneId=" + bdZoneId + "&actionId=" + bdActionId,
    method: "DELETE"
};
  
request ( options,
    function (error, response, body) {
        if (error) {
            console.log(error);
        }
        console.log(JSON.stringify(response.body));
    }
);
package com.bluedotinnovation.action;
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 Action client demonstrates deleting an action from an existing zone using Apache HTTP client libraries.
 */
public class DeleteAction 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 bdApiKey         = "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 updated. This can be fetched by calling GET Zones API.
        String bdActionId       = "8613a1ed-e1bd-4017-9bac-37100ebb4e00"; //This is the ID of the action being deleted. This can be fetched by calling GET Zones API
        String bdRestUrl        = "https://api.bluedotinnovation.com/1/actions?customerApiKey="+ bdCustomerApiKey + "&apiKey=" + bdApiKey +
                "&zoneId=" + bdZoneId + "&actionId=" + bdActionId;
         
        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("Action 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 Action client demonstrates deleting an action using the id provided, through http web api library
*/
namespace BluedotPublicApiClient.actionclient
{
    class DeleteAction
    {
        public void delete()
        {
            String bdCustomerApiKey     = "835d9460-7b91-11e4-bcb7-a0481cdc3311"; //This key is generated by Bluedot Point Access UI when your account is created
            String bdApplicationApiKey  = "e9224a1b-7f10-4033-82f7-c4d1dfc91825"; //This apiKey is generated when you create an application
            String bdZoneId             = "3846fa1d-11f7-4044-8eab-0977f90d987e"; //This is the ID of the zone being updated.
            String actionId             = "fe6c357a-5273-4f95-8980-2e37ef2dc115"; //This is the ID of the action being deleted.
            String bdRestBaseUrl        = "https://api.bluedotinnovation.com/1/actions?";
            String bdRestUrl        = bdRestBaseUrl + "customerApiKey=" + bdCustomerApiKey + "&apiKey" + bdApplicationApiKey + "&zoneId=" + bdZoneId+ "&actionId=" + actionId;
            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