Summary

The removeFileLabels() mutation removes one or more labels from a file in a LogScale repository or view. File labels organize and filter uploaded lookup files alongside dashboards and actions. Only the specified labels are removed; any other labels on the file remain. The mutation accepts up to 100 labels per call and returns the updated file on success, or null with errors on failure.

Syntax

graphql
removeFileLabels(
      input: RemoveFileLabels!
   ): File

The input argument requires the view or repository name, the file name, and a list of labels to remove. Use the repository() query to retrieve file names for a repository.

Hide Query Example

Show Files Query

Input parameters

Provide the view or repository name in viewName, the file name in fileName, and the labels to remove in labels. Only the labels you specify are removed; all other labels on the file remain. Passing a label that does not exist on the file is not an error. Use the repository() query to retrieve file names.

Table: RemoveFileLabels Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
fileNameStringyes   Name of the file.
labelsStringyes   Labels to remove from a file, at most 100 at a time.
viewNameRepoOrViewNameyes   Name of the view for the file.

Example

Raw
graphql
mutation {
  removeFileLabels(
    input: { 
      viewName: "humio",
      fileName: "my-file.txt",
      labels: [ "bobs-files" ]
    }
  )
  { labels }
}
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 {
  removeFileLabels(
    input: { 
      viewName: \"humio\",
      fileName: \"my-file.txt\",
      labels: [ \"bobs-files\" ]
    }
  )
  { labels }
}"
}
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 {
  removeFileLabels(
    input: { 
      viewName: \"humio\",
      fileName: \"my-file.txt\",
      labels: [ \"bobs-files\" ]
    }
  )
  { labels }
}"
}
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 { ^
  removeFileLabels( ^
    input: {  ^
      viewName: \"humio\", ^
      fileName: \"my-file.txt\", ^
      labels: [ \"bobs-files\" ] ^
    } ^
  ) ^
  { labels } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  removeFileLabels(
    input: { 
      viewName: \"humio\",
      fileName: \"my-file.txt\",
      labels: [ \"bobs-files\" ]
    }
  )
  { labels }
}"
}'
    "$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 {
  removeFileLabels(
    input: { 
      viewName: \"humio\",
      fileName: \"my-file.txt\",
      labels: [ \"bobs-files\" ]
    }
  )
  { labels }
}";
$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 {
  removeFileLabels(
    input: { 
      viewName: \"humio\",
      fileName: \"my-file.txt\",
      labels: [ \"bobs-files\" ]
    }
  )
  { labels }
}"
}'''

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 {
  removeFileLabels(
    input: { 
      viewName: \"humio\",
      fileName: \"my-file.txt\",
      labels: [ \"bobs-files\" ]
    }
  )
  { labels }
}"
}
);


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": {
    "removeFileLabels": {
      "labels": [ "admin-files" ],
    }
  }
}

Returned values

The mutation returns the updated File object on success, or null with errors on failure (for example, if the file or view does not exist). Use labels to verify the labels remaining on the file. Available fields also include the file name, creation timestamp, and modification timestamp.

Table: File Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
allowedActionsAssetActionyes Short-Term Allowed asset actions
contentHashStringyes Long-Term  
createdAtDateTimeyes Long-Term  
createdByStringyes Long-Term  
fileSizeBytesLong  Long-Term  
labelsStringyes Short-Term Labels associated with this file
modifiedAtDateTimeyes Long-Term  
modifiedByStringyes Long-Term  
nameAndPathFileNameAndPathyes Long-Term  
packagePackageInstallation  Long-Term  
packageIdVersionedPackageSpecifier  Long-Term  
resourceStringyes Short-Term The resource identifier for this file.