Update Workspace Access Restrictions
Update the access restriction settings of the specified workspace, or revert it to the organization settings.
REQUEST URI
https://<ZohoAnalytics_Server_URI>/restapi/v2/security-controls/workspaces/<workspace-id>/access-restrictions
Put
oauthscope: ZohoAnalytics.metadata.update
QUERY PARAMETERS
| Description |
|---|---|
| CONFIG* | JSONObject Config parameter specifications are available in the below section. |
FIELDS FOR CONFIG JSON
| Description |
|---|---|
| useOrganizationSettings | Boolean Controls whether the workspace uses the organization-level access restriction settings. Supported values: "true", "false" true - The workspace inherits the organization settings and any workspace-level settings are discarded. No section keys can be specified in the same request. false - The workspace uses its own settings specified in the section keys. To create a workspace-level override, this key must be set to false. This key is mandatory if no section key is specified. Sample: {"useOrganizationSettings":false} |
| shareViews | JSONObject The domain restriction settings applied when views are shared with other users. Maximum length - 30000 characters. Check the table Structure of shareViews for more details. Sample: {"shareViews":{"domainRestrictionEnabled":true,"trustedDomains":["example.com","partner.example.org"]}} |
| privateLinks | JSONObject The settings of private links (publish links), including their domain restriction. Maximum length - 30000 characters. Check the table Structure of privateLinks, publicViews and emailViews for more details. Sample: {"privateLinks":{"enabled":false}} |
| publicViews | JSONObject The settings of public view sharing, including its domain restriction. Maximum length - 30000 characters. Check the table Structure of privateLinks, publicViews and emailViews for more details. Sample: {"publicViews":{"enabled":false}} |
| exportViews | JSONObject The settings of view export. Maximum length - 100 characters. Check the table Structure of exportViews for more details. Sample: {"exportViews":{"enabled":true}} |
| emailViews | JSONObject The settings of email schedules and data alerts, including their domain restriction. Maximum length - 30000 characters. This key can be specified only when exportViews.enabled is true or is set to true in the same request.Check the table Structure of privateLinks, publicViews and emailViews for more details. Sample: {"emailViews":{"enabled":true,"domainRestrictionEnabled":true,"trustedDomains":["example.com"]}} |
Note: Workspace-level settings can be configured only when access restriction is enabled at the organization level.
| Description |
|---|---|
| domainRestrictionEnabled | Boolean Controls whether views can be shared only with users of the trusted domains. Supported values: "true", "false" Sample: {"domainRestrictionEnabled":true} |
| trustedDomains | JSONArray The list of trusted domain names. Each entry must be a valid domain name. Maximum entries - 100. Maximum length of each domain - 250 characters. This key is mandatory when domainRestrictionEnabled is enabled for the first time.Sample: {"trustedDomains":["zylker.com","zylker.net"]} |
Note: Trusted domains can be specified only when domainRestrictionEnabled is true or is set to true in the same request.
Note: When domain restriction is enabled, the list of trusted domains must not be empty.
Structure of privateLinks, publicViews and emailViews
| Description |
|---|---|
| enabled | Boolean Controls whether the feature is enabled. privateLinks - Private links (publish links). publicViews - Public view sharing. emailViews - Email schedules and data alerts. Supported values: "true", "false" Sample: {"enabled":true} |
| domainRestrictionEnabled | Boolean Controls whether the feature is restricted to the trusted domains. Supported values: "true", "false" Sample: {"domainRestrictionEnabled":true} |
| trustedDomains | JSONArray The list of trusted domain names. Each entry must be a valid domain name. Maximum entries - 100. Maximum length of each domain - 250 characters. This key is mandatory when domainRestrictionEnabled is enabled for the first time.Sample: {"trustedDomains":["zylker.com"]} |
Note: These three objects share the same structure.
Note: When the feature is disabled and remains disabled, domainRestrictionEnabled and trustedDomains must not be specified.
Note: When the feature is disabled in the same request, domainRestrictionEnabled can only be set to false and trustedDomains can only be an empty array.
Structure of exportViews
| Description |
|---|---|
| enabled* | Boolean Controls whether views can be exported. Supported values: "true", "false" This key is mandatory when exportViews is specified.Sample: {"enabled":true} |
Note: Disabling export also disables email schedules and data alerts (emailViews), even if emailViews is not specified in the request.
Sample Request:
Copiedcurl "https://analyticsapi.zoho.com/restapi/v2/security-controls/workspaces/<workspace-id>/access-restrictions" \
-X 'PUT' \
-H 'ZANALYTICS-ORGID: <org-id>' \
-H 'Authorization: Zoho-oauthtoken <access_token>' \
--data-urlencode 'CONFIG={"useOrganizationSettings":false,"shareViews":{"domainRestrictionEnabled":true,"trustedDomains":["example.com","partner.example.org"]},"privateLinks":{"enabled":false},"publicViews":{"enabled":false},"exportViews":{"enabled":true},"emailViews":{"enabled":true,"domainRestrictionEnabled":true,"trustedDomains":["example.com"]}}'Copiedusing System;
using System.Collections.Generic;
using System.Text.Json;
using ZohoAnalytics;
namespace ZohoAnalyticsTest
{
class Program
{
long orgId = 55522777;
public void UpdateWorkspaceAccessRestrictions(IAnalyticsClient ac)
{
long workspaceId = 35130000001055707L;
Dictionary<string, object> config = JsonSerializer.Deserialize<Dictionary<string, object>>("{\"useOrganizationSettings\":false,\"shareViews\":{\"domainRestrictionEnabled\":true,\"trustedDomains\":[\"example.com\",\"partner.example.org\"]},\"privateLinks\":{\"enabled\":false},\"publicViews\":{\"enabled\":false},\"exportViews\":{\"enabled\":true},\"emailViews\":{\"enabled\":true,\"domainRestrictionEnabled\":true,\"trustedDomains\":[\"example.com\"]}}");
IWorkspaceAPI workspace = ac.GetWorkspaceInstance(orgId, workspaceId);
workspace.UpdateWorkspaceAccessRestrictions(config);
Console.WriteLine("success");
}
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.UpdateWorkspaceAccessRestrictions(ac);
}
}
}Copiedpackage main
import (
"fmt"
ZAnalytics "zoho/pkg/analyticsclient"
)
var (
clientId = "1000.xxxxxxx"
clientSecret = "xxxxxxx"
refreshToken = "1000.xxxxxxx.xxxxxxx"
orgId = "55522777"
)
func UpdateWorkspaceAccessRestrictions(ac ZAnalytics.Client) {
workspaceid := "35130000001055707"
config := map[string]interface{}{
"useOrganizationSettings": false,
"shareViews": map[string]interface{}{
"domainRestrictionEnabled": true,
"trustedDomains": []string{"example.com", "partner.example.org"},
},
"privateLinks": map[string]interface{}{
"enabled": false,
},
"publicViews": map[string]interface{}{
"enabled": false,
},
"exportViews": map[string]interface{}{
"enabled": true,
},
"emailViews": map[string]interface{}{
"enabled": true,
"domainRestrictionEnabled": true,
"trustedDomains": []string{"example.com"},
},
}
workspace := ZAnalytics.GetWorkspaceInstance(&ac, orgId, workspaceid)
exception := workspace.UpdateWorkspaceAccessRestrictions(config)
if exception != nil {
fmt.Println(exception.ErrorMessage)
return
}
fmt.Println("success")
}
func main() {
ac := ZAnalytics.GetAnalyticsClient(clientId, clientSecret, refreshToken)
UpdateWorkspaceAccessRestrictions(ac)
}Copiedimport com.zoho.analytics.client.*;
import org.json.*;
public class Test {
private long orgId = 55522777l;
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.updateWorkspaceAccessRestrictions(ac);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void updateWorkspaceAccessRestrictions(AnalyticsClient ac) throws Exception {
long workspaceId = 35130000001055707l;
JSONObject config = new JSONObject("{\"useOrganizationSettings\":false,\"shareViews\":{\"domainRestrictionEnabled\":true,\"trustedDomains\":[\"example.com\",\"partner.example.org\"]},\"privateLinks\":{\"enabled\":false},\"publicViews\":{\"enabled\":false},\"exportViews\":{\"enabled\":true},\"emailViews\":{\"enabled\":true,\"domainRestrictionEnabled\":true,\"trustedDomains\":[\"example.com\"]}}");
WorkspaceAPI workspace = ac.getWorkspaceInstance(orgId, workspaceId);
workspace.updateWorkspaceAccessRestrictions(config);
System.out.println("success");
}
}Copied<?php
require 'AnalyticsClient.php';
class Test {
public $ac;
public $org_id = "55522777";
function __construct() {
$this->ac = new AnalyticsClient("1000.xxxxxxx", "xxxxxxx", "1000.xxxxxxx.xxxxxxx");
}
function updateWorkspaceAccessRestrictions() {
$workspace_id = "35130000001055707";
$config = array(
"useOrganizationSettings" => false,
"shareViews" => array(
"domainRestrictionEnabled" => true,
"trustedDomains" => array("example.com", "partner.example.org")
),
"privateLinks" => array(
"enabled" => false
),
"publicViews" => array(
"enabled" => false
),
"exportViews" => array(
"enabled" => true
),
"emailViews" => array(
"enabled" => true,
"domainRestrictionEnabled" => true,
"trustedDomains" => array("example.com")
)
);
$workspace = $this->ac->getWorkspaceInstance($this->org_id, $workspace_id);
$workspace->updateWorkspaceAccessRestrictions($config);
echo "success";
}
}
$obj = new Test();
$obj->updateWorkspaceAccessRestrictions();
?>Copiedfrom AnalyticsClient import AnalyticsClient
class Config:
CLIENTID = "1000.xxxxxxx"
CLIENTSECRET = "xxxxxxx"
REFRESHTOKEN = "1000.xxxxxxx.xxxxxxx"
ORGID = "55522777"
class Sample:
ac = AnalyticsClient(Config.CLIENTID, Config.CLIENTSECRET, Config.REFRESHTOKEN)
def update_workspace_access_restrictions(self, ac):
workspace_id = "35130000001055707"
config = {
"useOrganizationSettings": False,
"shareViews": {
"domainRestrictionEnabled": True,
"trustedDomains": ["example.com", "partner.example.org"]
},
"privateLinks": {
"enabled": False
},
"publicViews": {
"enabled": False
},
"exportViews": {
"enabled": True
},
"emailViews": {
"enabled": True,
"domainRestrictionEnabled": True,
"trustedDomains": ["example.com"]
}
}
workspace = ac.get_workspace_instance(Config.ORGID, workspace_id)
workspace.update_workspace_access_restrictions(config)
print("success")
obj = Sample()
obj.update_workspace_access_restrictions(obj.ac)Copiedvar analyticsClient = require('./AnalyticsClient');
var ac = new analyticsClient('1000.xxxxxxx', 'xxxxxxx', '1000.xxxxxxx.xxxxxxx');
var orgId = '55522777';
var workspaceId = "35130000001055707";
var config = {
"useOrganizationSettings": false,
"shareViews": {
"domainRestrictionEnabled": true,
"trustedDomains": ["example.com", "partner.example.org"]
},
"privateLinks": {
"enabled": false
},
"publicViews": {
"enabled": false
},
"exportViews": {
"enabled": true
},
"emailViews": {
"enabled": true,
"domainRestrictionEnabled": true,
"trustedDomains": ["example.com"]
}
};
var workspace = ac.getWorkspaceInstance(orgId, workspaceId);
workspace.updateWorkspaceAccessRestrictions(config).then(() => { console.log("success"); }).catch((error) => { console.log(error); });CopiedorgId = "55522777";
workspaceId = "35130000001055707";
headersMap = Map();
headersMap.put("ZANALYTICS-ORGID", orgId);
config = {"useOrganizationSettings": false, "shareViews": {"domainRestrictionEnabled": true, "trustedDomains": ["example.com", "partner.example.org"]}, "privateLinks": {"enabled": false}, "publicViews": {"enabled": false}, "exportViews": {"enabled": true}, "emailViews": {"enabled": true, "domainRestrictionEnabled": true, "trustedDomains": ["example.com"]}};
response = invokeurl
parameters = "CONFIG=" + zoho.encryption.urlEncode(config.toString());
[
url :"https://analyticsapi.zoho.com/restapi/v2/security-controls/workspaces/" + workspaceId + "/access-restrictions"
type :PUT
parameters:parameters
headers:headersMap
connection:"analytics_oauth_connection"
];
info response;Copiedrequire 'zoho_analytics_client'
class Config
ORGID = "55522777"
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 update_workspace_access_restrictions
workspace_id = "35130000001055707"
config = {
"useOrganizationSettings" => false,
"shareViews" => {
"domainRestrictionEnabled" => true,
"trustedDomains" => ["example.com", "partner.example.org"]
},
"privateLinks" => {
"enabled" => false
},
"publicViews" => {
"enabled" => false
},
"exportViews" => {
"enabled" => true
},
"emailViews" => {
"enabled" => true,
"domainRestrictionEnabled" => true,
"trustedDomains" => ["example.com"]
}
}
workspace = @ac.get_workspace_instance(Config::ORGID, workspace_id)
workspace.update_workspace_access_restrictions(config)
puts "success"
end
end
obj = Sample.new
obj.update_workspace_access_restrictionsDownload client libraries: C# | GO | JAVA | PHP | PYTHON | NodeJS | Ruby
Sample value for CONFIG parameter:
Copied{
"useOrganizationSettings": false,
"shareViews": {
"domainRestrictionEnabled": true,
"trustedDomains": [
"example.com",
"partner.example.org"
]
},
"privateLinks": {
"enabled": false
},
"publicViews": {
"enabled": false
},
"exportViews": {
"enabled": true
},
"emailViews": {
"enabled": true,
"domainRestrictionEnabled": true,
"trustedDomains": [
"example.com"
]
}
}Sample Response:
CopiedHTTP/1.1 204 No Content