Get View Metadata For Alert

Get the columns, operators, rule types, thresholds and anomalies of the specified view that can be used to create an alert.

REQUEST URI

https://<ZohoAnalytics_Server_URI>/restapi/v2/workspaces/<workspace-id>/views/<view-id>/alerts/metadata

Get

oauthscope: ZohoAnalytics.metadata.read

Sample Request:

Copiedcurl "https://analyticsapi.zoho.com/restapi/v2/workspaces/35130000001055707/views/35130000001055717/alerts/metadata" -H 'ZANALYTICS-ORGID: <org-id>' -H 'Authorization: Zoho-oauthtoken <access_token>'
Copiedusing System;
using System.Collections.Generic;
using System.Text.Json;
using ZohoAnalytics;

namespace ZohoAnalyticsTest
{
    class Program
    {
        long orgId = 55522777;
        long workspaceId = 35130000001055707;
        long viewId = 35130000001055717;

        public void GetViewMetadataForAlert(IAnalyticsClient ac)
        {
            IViewAPI view = ac.GetViewInstance(orgId, workspaceId, viewId);
            JsonElement result = view.GetViewMetadataForAlert();
            Console.WriteLine(result);
        }

        static void Main(string[] args)
        {
            string clientId = "1000.xxxxxxx";
            string clientSecret = "xxxxxxx";
            string refreshToken = "1000.xxxxxxx.xxxxxxx";
            IAnalyticsClient ac = new AnalyticsClient(clientId, clientSecret, refreshToken);
            Program obj = new Program();
            obj.GetViewMetadataForAlert(ac);
        }
    }
}
Copiedpackage main

import (
    "fmt"
    ZAnalytics "zoho/pkg/analyticsclient"
)

var (
    clientId = "1000.xxxxxxx"
    clientSecret = "xxxxxxx"
    refreshToken = "1000.xxxxxxx.xxxxxxx"
    orgId = "55522777"
    workspaceId = "35130000001055707"
    viewId = "35130000001055717"
)

func GetViewMetadataForAlert(ac ZAnalytics.Client) {
    view := ZAnalytics.GetViewInstance(&ac, orgId, workspaceId, viewId)
    result, exception := view.GetViewMetadataForAlert()
    if exception != nil {
        fmt.Println(exception.ErrorMessage)
        return
    }
    fmt.Println(result)
}

func main() {
    ac := ZAnalytics.GetAnalyticsClient(clientId, clientSecret, refreshToken)
    GetViewMetadataForAlert(ac)
}
Copiedimport com.zoho.analytics.client.*;
import org.json.*;

public class Test {
    private long orgId = 55522777l;
    private long workspaceId = 35130000001055707l;
    private long viewId = 35130000001055717l;

    public static void main(String args[]) {
        String clientId = "1000.xxxxxxx";
        String clientSecret = "xxxxxxx";
        String refreshToken = "1000.xxxxxxx.xxxxxxx";
        Test tObj = new Test();
        AnalyticsClient ac = new AnalyticsClient(clientId, clientSecret, refreshToken);
        try {
            tObj.getViewMetadataForAlert(ac);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void getViewMetadataForAlert(AnalyticsClient ac) throws Exception {
        ViewAPI view = ac.getViewInstance(orgId, workspaceId, viewId);
        JSONObject result = view.getViewMetadataForAlert();
        System.out.println(result);
    }
}
Copied<?php
require 'AnalyticsClient.php';

class Test {
    public $ac;
    public $org_id = "55522777";
    public $workspace_id = "35130000001055707";
    public $view_id = "35130000001055717";

    function __construct() {
        $this->ac = new AnalyticsClient("1000.xxxxxxx", "xxxxxxx", "1000.xxxxxxx.xxxxxxx");
    }

    function getViewMetadataForAlert() {
        $view = $this->ac->getViewInstance($this->org_id, $this->workspace_id, $this->view_id);
        $response = $view->getViewMetadataForAlert();
        print_r($response);
    }
}

$obj = new Test();
$obj->getViewMetadataForAlert();
?>
Copiedfrom AnalyticsClient import AnalyticsClient

class Config:
    CLIENTID = "1000.xxxxxxx"
    CLIENTSECRET = "xxxxxxx"
    REFRESHTOKEN = "1000.xxxxxxx.xxxxxxx"
    ORGID = "55522777"
    WORKSPACEID = "35130000001055707"
    VIEWID = "35130000001055717"

class Sample:
    ac = AnalyticsClient(Config.CLIENTID, Config.CLIENTSECRET, Config.REFRESHTOKEN)

    def get_view_metadata_for_alert(self, ac):
        view = ac.get_view_instance(Config.ORGID, Config.WORKSPACEID, Config.VIEWID)
        result = view.get_view_metadata_for_alert()
        print(result)

obj = Sample()
obj.get_view_metadata_for_alert(obj.ac)
Copiedvar analyticsClient = require('./AnalyticsClient');
var ac = new analyticsClient('1000.xxxxxxx', 'xxxxxxx', '1000.xxxxxxx.xxxxxxx');
var orgId = '55522777';
var workspaceId = '35130000001055707';
var viewId = '35130000001055717';

var view = ac.getViewInstance(orgId, workspaceId, viewId);
view.getViewMetadataForAlert().then((result) => { console.log(result); }).catch((error) => { console.log(error); });
CopiedorgId = "55522777";
workspaceId = "35130000001055707";
viewId = "35130000001055717";
headersMap = Map();
headersMap.put("ZANALYTICS-ORGID", orgId);
response = invokeurl
[
  url :"https://analyticsapi.zoho.com/restapi/v2/workspaces/" + workspaceId + "/views/" + viewId + "/alerts/metadata"
  type :GET
  headers:headersMap
  connection:"analytics_oauth_connection"
];
info response;
Copiedrequire 'zoho_analytics_client'

class Config
  ORGID = "55522777"
  WORKSPACEID = "35130000001055707"
  VIEWID = "35130000001055717"
end

class Sample
  def initialize
    @ac = AnalyticsClient.new.with_data_center("US").with_oauth({
      "clientId" => "1000.xxxxxxx",
      "clientSecret" => "xxxxxxx",
      "refreshToken" => "1000.xxxxxxx.xxxxxxx"
    }).build
  end

  def get_view_metadata_for_alert
    view = @ac.get_view_instance(Config::ORGID, Config::WORKSPACEID, Config::VIEWID)
    result = view.get_view_metadata_for_alert
    puts result
  end
end

obj = Sample.new
obj.get_view_metadata_for_alert

Download client libraries:  C# | GO | JAVA | PHP | PYTHON | NodeJS | Ruby

Sample Response:

CopiedHTTP/1.1 200 OK
Content-Type:application/json;charset=UTF-8

{
    "status": "success",
    "summary": "Get view metadata for alert",
    "data": {
        "viewType": "AnalysisView",
        "viewColumns": [
            {
                "viewColumnIndex": "1",
                "axis": "X",
                "axisType": "XAXIS",
                "axisDisplayName": "Region",
                "operation": "GROUP",
                "dataType": "PLAIN",
                "viewId": "137687000006991601",
                "formulaId": "",
                "thresholds": [],
                "allowedOperators": ["is", "isnot", "isn", "notisn"],
                "allowedRuleTypes": ["constant"]
            },
            {
                "viewColumnIndex": "2",
                "axis": "Y",
                "axisType": "YAXIS",
                "axisDisplayName": "Sales",
                "operation": "SUM",
                "dataType": "NUMBER",
                "viewId": "137687000006991601",
                "formulaId": "",
                "thresholds": ["T1", "T2"],
                "allowedOperators": ["is", "isnot", "gt", "lt", "gte", "lte", "btw", "notbtw", "isn", "notisn"],
                "allowedRuleTypes": ["constant", "column", "threshold"]
            },
            {
                "viewColumnIndex": "3",
                "axis": "Y",
                "axisType": "YAXIS",
                "axisDisplayName": "Profit",
                "operation": "SUM",
                "dataType": "NUMBER",
                "viewId": "137687000006991601",
                "formulaId": "",
                "thresholds": [],
                "allowedOperators": ["is", "isnot", "gt", "lt", "gte", "lte", "btw", "notbtw", "isn", "notisn"],
                "allowedRuleTypes": ["constant", "column"]
            }
        ],
        "anomalies": [
            {
                "viewColumnIndex": "2",
                "anomalyName": "Sales Spike"
            }
        ],
        "allowedAnomalyOperators": ["sinceLastAlert"]
    }
}