Summary

The updateViewPermissionsTokenPermissions() mutation updates the permissions assigned to a view permissions token. Use this mutation to change the access level of a token without deleting and recreating it. Identify the token by its unique ID. Supply a complete replacement permissions list and a replacement assetPermissionAssignments list; the mutation overwrites both sets of permissions on the token. The assetPermissionAssignments field, available from version 1.170, controls per-asset access to resources such as dashboards and saved queries within the token's views. Pass an empty list to remove all existing per-asset overrides.

Syntax

graphql
updateViewPermissionsTokenPermissions(
      input: UpdateViewPermissionsTokenPermissionsInput!
   ): String!

The mutation accepts a single required input argument of type UpdateViewPermissionsTokenPermissionsInput. All three fields in the input type are required: the token ID, the replacement view-level permissions list, and the replacement asset-level permissions list. The mutation returns a non-null String containing the unique identifier of the updated token.

Use the roles() query to list valid Permission enum values.

Input parameters

The id field is the unique identifier of the token to update. The permissions field accepts one or more Permission enum values; the supplied list replaces all existing view-level permissions for the token. Use the roles() query to list valid Permission enum values. The assetPermissionAssignments field, available from version 1.170, accepts a list of per-asset permission entries. Each entry requires an assetResourceIdentifier string identifying the asset and a permissions value of type AssetPermission. The supplied list replaces all existing asset-level permissions; pass an empty list to remove all per-asset overrides.

The following table describes the fields of the UpdateViewPermissionsTokenPermissionsInput type:

Table: UpdateViewPermissionsTokenPermissionsInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
idStringyes Long-Term The unique identifier of the token.
permissionsPermissionyes Long-Term A list of permissions associated with the token. See Permission.

Example

Raw
graphql
mutation {
  updateViewPermissionsTokenPermissions( input:
    { id: "abc123",
      permissions: [ ReadAccess ] } )
}
Mac OS or Linux (curl)
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  updateViewPermissionsTokenPermissions( input:
    { id: \"abc123\",
      permissions: [ ReadAccess ] } )
}"
}
EOF
Mac OS or Linux (curl) One-line
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  updateViewPermissionsTokenPermissions( input:
    { id: \"abc123\",
      permissions: [ ReadAccess ] } )
}"
}
EOF
Windows Cmd and curl
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql ^
    -H "Authorization: Bearer $TOKEN" ^
    -H "Content-Type: application/json" ^
    -d @'{"query" : "mutation { ^
  updateViewPermissionsTokenPermissions( input: ^
    { id: \"abc123\", ^
      permissions: [ ReadAccess ] } ) ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  updateViewPermissionsTokenPermissions( input:
    { id: \"abc123\",
      permissions: [ ReadAccess ] } )
}"
}'
    "$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $query = "mutation {
  updateViewPermissionsTokenPermissions( input:
    { id: \"abc123\",
      permissions: [ ReadAccess ] } )
}";
$query =~ s/\n/ /g;
my $json = sprintf('{"query" : "%s"}',$query);
my $req = HTTP::Request->new("POST", $uri );

$req->header("Authorization" => "Bearer $TOKEN");
$req->header("Content-Type" => "application/json");

$req->content( $json );

my $lwp = LWP::UserAgent->new;

my $result = $lwp->request( $req );

print $result->{"_content"},"\n";
Python
python
#! /usr/local/bin/python3

import requests

url = '$YOUR_LOGSCALE_URL/graphql'
mydata = r'''{"query" : "mutation {
  updateViewPermissionsTokenPermissions( input:
    { id: \"abc123\",
      permissions: [ ReadAccess ] } )
}"
}'''

resp = requests.post(url,
                     data = mydata,
                     headers = {
   "Authorization" : "Bearer $TOKEN",
   "Content-Type" : "application/json"
}
)

print(resp.text)
Node.js
javascript
const https = require('https');

const data = JSON.stringify(
    {"query" : "mutation {
  updateViewPermissionsTokenPermissions( input:
    { id: \"abc123\",
      permissions: [ ReadAccess ] } )
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL',
  path: 'graphql',
  port: 443,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length,
    Authorization: 'BEARER ' + process.env.TOKEN,
    'User-Agent': 'Node',
  },
};

const req = https.request(options, (res) => {
  let data = '';
  console.log(`statusCode: ${res.statusCode}`);

  res.on('data', (d) => {
    data += d;
  });
  res.on('end', () => {
    console.log(JSON.parse(data).data);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.write(data);
req.end();
Example Responses
Success (HTTP Response Code 200 OK)
json
{
  "data": {
    "updateViewPermissionsTokenPermissions": "abc123"
  }
}

Returned values

The mutation returns a non-null String containing the unique identifier of the updated token.