Summary

The updateIPFilter() mutation modifies an existing IP filter in LogScale. IP filters control inbound access using allow and deny directives paired with IP addresses or CIDR ranges. Use this mutation to change the filter name, replace the filter expression, or both. You must supply the filter's unique identifier; obtain it from the ipFilters() query. To create a new IP filter, use createIPFilter(). To remove a filter, use deleteIPFilter().

Syntax

graphql
updateIPFilter(
      input: IPFilterUpdateInput!
   ): IPFilter!

The mutation accepts a single required argument, input, of type IPFilterUpdateInput!. The input requires the id of the filter to update. Provide a new name, a new ipFilter expression, or both. When you supply ipFilter, LogScale replaces the entire existing expression; partial expression edits are not supported. The mutation returns a non-null IPFilter! object representing the updated filter.

Input parameters

Provide the unique identifier of the filter to update and the fields to change. Omitting ipFilter or name leaves those fields unchanged. The following table describes the available fields.

Table: IPFilterUpdateInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
idStringyes Long-Term The unique identifier of the IP filter to update. Use the ipFilters() query to retrieve existing filter identifiers.
ipFilterString  Long-Term The replacement filter expression. Each line pairs an allow or deny directive with an IP address or CIDR range, for example, allow 10.0.0.0/24. Supplying this field replaces the entire existing expression. Omitting it leaves the current expression unchanged. For expression syntax, see the IP filter configuration reference.
nameString  Long-Term A new display name for the filter. Omitting this field leaves the current name unchanged.

Example

Raw
graphql
mutation {
  updateIPFilter( input:
       { id: "abc123"
         name: "my-filter",
         ipFilter: "deny all\ndeny 127.0.0.1\nallow 10.0.0.0/24\nallow 192.168.0.0/8\n"
      }
  )
  { id }
}
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 {
  updateIPFilter( input:
       { id: \"abc123\"
         name: \"my-filter\",
         ipFilter: \"deny all\ndeny 127.0.0.1\nallow 10.0.0.0/24\nallow 192.168.0.0/8\n\"
      }
  )
  { id }
}"
}
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 {
  updateIPFilter( input:
       { id: \"abc123\"
         name: \"my-filter\",
         ipFilter: \"deny all\ndeny 127.0.0.1\nallow 10.0.0.0/24\nallow 192.168.0.0/8\n\"
      }
  )
  { id }
}"
}
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 { ^
  updateIPFilter( input: ^
       { id: \"abc123\" ^
         name: \"my-filter\", ^
         ipFilter: \"deny all\ndeny 127.0.0.1\nallow 10.0.0.0/24\nallow 192.168.0.0/8\n\" ^
      } ^
  ) ^
  { id } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  updateIPFilter( input:
       { id: \"abc123\"
         name: \"my-filter\",
         ipFilter: \"deny all\ndeny 127.0.0.1\nallow 10.0.0.0/24\nallow 192.168.0.0/8\n\"
      }
  )
  { id }
}"
}'
    "$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 {
  updateIPFilter( input:
       { id: \"abc123\"
         name: \"my-filter\",
         ipFilter: \"deny all\ndeny 127.0.0.1\nallow 10.0.0.0/24\nallow 192.168.0.0/8\n\"
      }
  )
  { id }
}";
$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 {
  updateIPFilter( input:
       { id: \"abc123\"
         name: \"my-filter\",
         ipFilter: \"deny all\ndeny 127.0.0.1\nallow 10.0.0.0/24\nallow 192.168.0.0/8\n\"
      }
  )
  { id }
}"
}'''

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 {
  updateIPFilter( input:
       { id: \"abc123\"
         name: \"my-filter\",
         ipFilter: \"deny all\ndeny 127.0.0.1\nallow 10.0.0.0/24\nallow 192.168.0.0/8\n\"
      }
  )
  { id }
}"
}
);


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": {
    "updateIPFilter": {
      "id": "abc123"
    }
  }
}

Returned values

The mutation returns a non-null IPFilter! object representing the updated filter. Request id to confirm the target filter, name to verify the display name, and ipFilter to confirm the expression LogScale recorded. The following table describes the available fields.

Table: IPFilter Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
idStringyes Long-Term The unique identifier for the IP filter.
ipFilterStringyes Long-Term The IP filter itself.
nameStringyes Long-Term The name for the IP filter.