updateSpecifications

Creates or updates the validation specifications for one or more index/collection pairs.

When the validation specifications are not correctly formatted, a detailed error message is returned to help with debugging.

Arguments

Copied to clipboard!
public async Task<JObject> UpdateSpecificationsAsync(
        string index,
        string collection,
        JObject specifications);
Argument Type Description
index
string
Index name
collection
string
Collection name
specifications
JObject
Specifications in JSON format

specifications

A JObject representing the specifications.

The JSON must follow the Specifications structure:

Copied to clipboard!
{
  "strict": "true",
  "fields": {
    "licence": {
      "mandatory": true,
      "type": "string"
    }
    // ... specification for each field
  }
}

Return

A JObject representing the specifications.

Usage

Copied to clipboard!
try {
  JObject specifications = JObject.Parse(@"{
    strict: false,
    fields: {
      license: {
        mandatory: true,
        type: 'string'
      }
    }
  }");
  JObject updatedSpecifications =
    await kuzzle.Collection.UpdateSpecificationsAsync(
      "nyc-open-data",
      "yellow-taxi",
      specifications
    );
  Console.WriteLine(updatedSpecifications.ToString(Formatting.None));
  /*
  {
    "strict": false,
    "fields": {
      "license": {
        "mandatory": true,
        "type": "string"
      }
    }
  }
  */
} catch (Exception e) {
  Console.WriteLine(e);
}