Summary

The clearCapacitiesForProductType() mutation clears the pool capacity for multiple organizations for a specified product type in a single operation. Organizations not listed in the input are left unchanged, as are other product types. If any part of the input is invalid โ€” for example, a non-existent organization ID โ€” no changes are made and the mutation returns 0. On success, it returns the number of organizations whose capacity was cleared.

Provide productType to identify the product type, and organizationIds with the IDs of the organizations to clear.

This mutation is available on a preview basis.

Syntax

graphql
clearCapacitiesForProductType(
      productType: String!,
      organizationIds: [String!]!
   ): Int!

Provide productType (required) โ€” a string identifying the product type, for example falconComplete or main. Provide organizationIds (required) โ€” a non-empty list of organization ID strings whose capacities to clear. If any ID is invalid, nothing is changed.

Returns a non-nullable Int! โ€” the count of organizations whose capacity was cleared.

Example

Raw
graphql
mutation {
  clearCapacitiesForProductType(
    productType: "main",
    organizationIds: ["org-abc123", "org-def456"]
  )
}
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 {
  clearCapacitiesForProductType(
    productType: \"main\",
    organizationIds: [\"org-abc123\", \"org-def456\"]
  )
}"
}
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 {
  clearCapacitiesForProductType(
    productType: \"main\",
    organizationIds: [\"org-abc123\", \"org-def456\"]
  )
}"
}
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 { ^
  clearCapacitiesForProductType( ^
    productType: \"main\", ^
    organizationIds: [\"org-abc123\", \"org-def456\"] ^
  ) ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  clearCapacitiesForProductType(
    productType: \"main\",
    organizationIds: [\"org-abc123\", \"org-def456\"]
  )
}"
}'
    "$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 {
  clearCapacitiesForProductType(
    productType: \"main\",
    organizationIds: [\"org-abc123\", \"org-def456\"]
  )
}";
$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 {
  clearCapacitiesForProductType(
    productType: \"main\",
    organizationIds: [\"org-abc123\", \"org-def456\"]
  )
}"
}'''

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 {
  clearCapacitiesForProductType(
    productType: \"main\",
    organizationIds: [\"org-abc123\", \"org-def456\"]
  )
}"
}
);


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": {
    "clearCapacitiesForProductType": 2
  }
}

Input Parameters

Both productType and organizationIds are required. If any organization ID in the list does not exist, the entire mutation is rejected and no capacities are cleared.

Table: Input Parameters and Datatypes

Parameter Type Required Default Description
This table contains all input parameters for this mutation.
organizationIds [String!]! yes ย  The IDs of the organizations whose pool capacity to clear for the specified product type. If any ID does not exist, no changes are made.
productType String! yes ย  The product type whose capacities to clear, for example falconComplete or main. Only this product type is affected; other product types are left unchanged.

Returned Values

Returns a non-nullable Int! โ€” the number of organizations whose capacity was cleared. Returns 0 if no changes were made, including when the mutation is rejected because of invalid input.