Summary

The setCapacitiesForProductType() mutation sets the pool capacity for multiple organizations for a specified product type in a single operation. Organizations not included 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 changed.

Provide productType to identify the product type, and capacities with one OrganizationCapacityInput entry per organization to update.

This mutation is available on a preview basis.

Syntax

graphql
setCapacitiesForProductType(
      productType: String!,
      capacities: [OrganizationCapacityInput!]!
   ): Int!

Provide productType (required) โ€” a string identifying the product type, for example falconComplete or main. Provide capacities (required) โ€” a non-empty list of OrganizationCapacityInput objects, each specifying an organization ID and pool capacity values. If any entry is invalid, nothing is changed.

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

Example

Raw
graphql
mutation {
  setCapacitiesForProductType(
    productType: "main",
    capacities: [
      {
        organizationId: "org-abc123",
        poolName: "pool-west",
        poolSize: 10000,
        organizationSizeInPool: 2500,
        summedOrganizationSizesInPool: 5000
      }
    ]
  )
}
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 {
  setCapacitiesForProductType(
    productType: \"main\",
    capacities: [
      {
        organizationId: \"org-abc123\",
        poolName: \"pool-west\",
        poolSize: 10000,
        organizationSizeInPool: 2500,
        summedOrganizationSizesInPool: 5000
      }
    ]
  )
}"
}
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 {
  setCapacitiesForProductType(
    productType: \"main\",
    capacities: [
      {
        organizationId: \"org-abc123\",
        poolName: \"pool-west\",
        poolSize: 10000,
        organizationSizeInPool: 2500,
        summedOrganizationSizesInPool: 5000
      }
    ]
  )
}"
}
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 { ^
  setCapacitiesForProductType( ^
    productType: \"main\", ^
    capacities: [ ^
      { ^
        organizationId: \"org-abc123\", ^
        poolName: \"pool-west\", ^
        poolSize: 10000, ^
        organizationSizeInPool: 2500, ^
        summedOrganizationSizesInPool: 5000 ^
      } ^
    ] ^
  ) ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  setCapacitiesForProductType(
    productType: \"main\",
    capacities: [
      {
        organizationId: \"org-abc123\",
        poolName: \"pool-west\",
        poolSize: 10000,
        organizationSizeInPool: 2500,
        summedOrganizationSizesInPool: 5000
      }
    ]
  )
}"
}'
    "$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 {
  setCapacitiesForProductType(
    productType: \"main\",
    capacities: [
      {
        organizationId: \"org-abc123\",
        poolName: \"pool-west\",
        poolSize: 10000,
        organizationSizeInPool: 2500,
        summedOrganizationSizesInPool: 5000
      }
    ]
  )
}";
$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 {
  setCapacitiesForProductType(
    productType: \"main\",
    capacities: [
      {
        organizationId: \"org-abc123\",
        poolName: \"pool-west\",
        poolSize: 10000,
        organizationSizeInPool: 2500,
        summedOrganizationSizesInPool: 5000
      }
    ]
  )
}"
}'''

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 {
  setCapacitiesForProductType(
    productType: \"main\",
    capacities: [
      {
        organizationId: \"org-abc123\",
        poolName: \"pool-west\",
        poolSize: 10000,
        organizationSizeInPool: 2500,
        summedOrganizationSizesInPool: 5000
      }
    ]
  )
}"
}
);


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": {
    "setCapacitiesForProductType": 1
  }
}

Input Parameters

Both productType and capacities are required. Each entry in capacities must include all fields defined by OrganizationCapacityInput. If any entry contains an invalid organization ID or value, the entire mutation is rejected.

Table: Input Parameters and Datatypes

Parameter Type Required Default Description
This table contains all input parameters for this mutation.
capacities [OrganizationCapacityInput!]! yes ย  A list of capacity entries, one per organization to update. Each entry must supply organizationId, poolName, poolSize, organizationSizeInPool, and summedOrganizationSizesInPool. If any entry is invalid, no changes are made.
productType String! yes ย  The product type whose capacities to set, 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 changed. Returns 0 if no changes were made, including when the mutation is rejected because of invalid input.