Configurations: P4 Code Review configurations
On this page:
Create a configuration
Summary
Create a configuration.
POST /api/v11/configurations
Description
Create a new configuration.
Parameters
| Parameter | Description | Type | Parameter Type |
Required |
|---|---|---|---|---|
id
|
Identifier for the configuration. | string | body | Yes |
name
|
Name of the configuration. | string | body | Yes |
enabled
|
Whether this configuration is active. | boolean | body | Yes |
dataRetentionLifetime
|
How long data is retained. For example, "6 months". | string | body | Yes |
timeout
|
Timeout in milliseconds for AI operations. | integer | body | Yes |
id
|
Identifier for the AI vendor configuration. | string | body | Yes |
aiVendor
|
Vendor name. | string | body | Yes |
aiPackageId |
1
|
integer | body | Yes |
aiPackageKey
|
Internal key identifying the package. | string | body | No |
aiPackageValue
|
Package name. | string | body | No |
aiModel
|
Model identifier, such as "gpt-4" | string | body | No |
aiPackageType
|
Description of what the package does. | string | body | Yes |
apiKey
|
API key used to authenticate with the vendor. | string | body | No |
aiMinCharLimit
|
Minimum number of characters. | integer | body | No |
aiMaxCharLimit
|
Maximum number of characters | integer | body | No |
apiEndPoint
|
Custom API endpoint, if applicable. | string or null |
body | No |
isDeleted
|
Whether the configuration is deleted. Default is false. |
boolean | body | No |
aiCommentPrompts
|
Contains prompt templates for different comment‑related tasks. | object | body | No |
improveComment
|
Possible prompt template. | string | body | No |
summarizeText
|
Possible prompt template. | string | body | No |
fixSpellingAndGrammar
|
Possible prompt template. | string | body | No |
customPrompt
|
Possible prompt template. | string | body | No |
Example usage
Create a configuration
curl -X POST -H "Content-Type: application/json" -u "username:ticket" -d "@mybodyfilename.txt" "https://myswarm-url/api/v11/configurations/"
The mybodyfilename.txt file contains the create configuration details:
{
"id": "ai_review",
"name": "Ai review",
"enabled": true,
"dataRetentionLifetime": "5 months",
"timeout": 500,
"aiVendors": [
{
"id": "aiModel1",
"aiVendor": "openAI",
"aiPackageId": 1,
"aiPackageKey": "openaiwithexplaincodeongpt4",
"aiPackageValue": "Open AI With Explain Code On GPT4",
"aiModel": "gpt-4",
"aiPackageType": "Explain the following code ",
"apiKey": "XXXXX",
"aiMinCharLimit": 100,
"aiMaxCharLimit": 7000,
"isDeleted": false,
"aiCommentPrompts": {
"improveComment": "placeholder",
"summarizeText": "placeholder",
"fixSpellingAndGrammar": "placeholder",
"customPrompt": ""
}
}
]
}
JSON Response:
{
"error": null,
"messages": [],
"data": {
"configurations": [
{
"id": "ai_review",
"name": "Ai review",
"enabled": true,
"dataRetentionLifetime": "5 months",
"timeout": 500,
"aiVendors": [
{
"id": "aiModel1",
"aiVendor": "openAI",
"aiPackageId": 1,
"aiPackageKey": "openaiwithexplaincodeongpt4",
"aiPackageValue": "Open AI With Explain Code On GPT4",
"aiModel": "gpt-4",
"aiPackageType": "Explain the following code ",
"apiKey": "xxxxx",
"aiMinCharLimit": 100,
"aiMaxCharLimit": 7000,
"apiEndPoint": null,
"isDeleted": false,
"aiCommentPrompts": {
"improveComment": "placeholder",
"summarizeText": "placeholder",
"fixSpellingAndGrammar": "placeholder",
"customPrompt": ""
}
}
]
}
]
}
}
If a request fails
<error code>:
-
400 invalid type given, The configuration id should be 'ai_review'
-
401 unauthorized
Patch a configuration
Summary
Update details for a configuration.
PATCH /api/v11/configurations/ai_review
Description
This patch method is for edits to the following fields: name, enabled, dataRetentionLifetime, and timeout.
To edit the AI Vendor fields, see Patch an AI vendor.
Parameters
| Parameter | Description | Type | Parameter Type |
Required |
|---|---|---|---|---|
dataRetentionLifetime
|
How long data is retained. For example, "6 months". | string | body | Yes |
timeout
|
Timeout in milliseconds for AI operations. | integer | body | Yes |
Example usage
curl -X PATCH -H "Content-Type: application/json" -u "username:ticket" -d "@mybodyfilename.txt" "https://myswarm-url/api/v11/configurations/ai_review"
The mybodyfilename.txt file contains the two fields to update:
{
"dataRetentionLifetime": "6 months",
"timeout": 600
}
JSON Response shows the updates on line 10 and 11:
{
"error": null,
"messages": [],
"data": {
"configurations": [
{
"id": "ai_review",
"name": "Ai review",
"enabled": true,
"dataRetentionLifetime": "6 months",
"timeout": 600,
"aiVendors": [
{
"id": "aiModel1",
"aiVendor": "openAI",
"aiPackageId": 1,
"aiPackageKey": "openaiwithexplaincodeongpt4",
"aiPackageValue": "Open AI With Explain Code On GPT4",
"aiModel": "gpt-4",
"aiPackageType": "Explain the following code ",
"apiKey": "xxxxx",
"aiMinCharLimit": 100,
"aiMaxCharLimit": 7000,
"apiEndPoint": null,
"isDeleted": false,
"aiCommentPrompts": {
"improveComment": "placeholder",
"summarizeText": "placeholder",
"fixSpellingAndGrammar": "placeholder",
"customPrompt": ""
}
}
]
}
]
}
}
If a request fails
<error code>:
-
400 Invalid boolean timeout value, The input is not an integer greater than '1'
-
401 unauthorized
Get a configuration
Summary
Get the details of a configuration.
GET /api/v11/configurations/{id}
Description
Returns the details of a configuration.
Parameters
| Parameter | Description | Type | Parameter Type |
Required |
|---|---|---|---|---|
id
|
Identifier for the configuration. | string | path | Yes |
Example usage
curl -u "username:password" "https://my-swarm-host/api/v11/configurations/ai_review
JSON Response:
{
"error": null,
"messages": [],
"data": {
"configurations": [
{
"id": "ai_review",
"name": "Ai review",
"enabled": true,
"dataRetentionLifetime": "6 months",
"timeout": 600,
"aiVendors": [
{
"id": "aiModel1",
"aiVendor": "openAI",
"aiPackageId": 1,
"aiPackageKey": "openaiwithexplaincodeongpt4",
"aiPackageValue": "Open AI With Explain Code On GPT4",
"aiModel": "gpt-4",
"aiPackageType": "Explain the following code ",
"apiKey": "xxxxx",
"aiMinCharLimit": 100,
"aiMaxCharLimit": 7000,
"apiEndPoint": null,
"isDeleted": false,
"aiCommentPrompts": {
"improveComment": "placeholder",
"summarizeText": "placeholder",
"fixSpellingAndGrammar": "placeholder",
"customPrompt": ""
}
}
]
}
]
}
}
If a request fails
<error code>:
-
400 Invalid configuration id given, Unknown configuration: ai_review1
-
401 unauthorized
Patch an AI vendor
Summary
Patch an AI vendor.
PATCH /api/v11/{config_id}/ai-vendors/{vendor_id}
Description
This patch method is for edits to the AI vendor fields.
To edit the name, enabled, dataRetentionLifetime, and timeout fields, see Patch a configuration.
Parameters
| Parameter | Description | Type | Parameter Type |
Required |
|---|---|---|---|---|
config_id
|
Identifier for the configuration. | string | path | Yes |
vendor_id
|
Identifier for the vendor | string | path | Yes |
Example usage
curl -X PATCH -H "Content-Type: application/json" -u "username:ticket" -d "@mybodyfilename.txt" "https://myswarm-url/api/v11/configurations/ai_review/ai-vendors/aiModel1"
The mybodyfilename.txt file contains the AI vendor fields to update:
{
"aiPackageType": "Explain the following code cleanly ",
"aiMinCharLimit": 2000,
"aiMaxCharLimit": 4000
}
JSON Response shows the updates on lines 20, 22, and 23:
{
"error": null,
"messages": [],
"data": {
"configurations": [
{
"id": "ai_review",
"name": "Ai review",
"enabled": true,
"dataRetentionLifetime": "6 months",
"timeout": 600,
"aiVendors": [
{
"id": "aiModel1",
"aiVendor": "openAI",
"aiPackageId": 1,
"aiPackageKey": "openaiwithexplaincodeongpt4",
"aiPackageValue": "Open AI With Explain Code On GPT4",
"aiModel": "gpt-4",
"aiPackageType": "Explain the following code cleanly ",
"apiKey": "xxxxx",
"aiMinCharLimit": 2000,
"aiMaxCharLimit": 4000,
"apiEndPoint": null,
"isDeleted": false,
"aiCommentPrompts": {
"improveComment": "placeholder",
"summarizeText": "placeholder",
"fixSpellingAndGrammar": "placeholder",
"customPrompt": ""
}
}
]
}
]
}
}
If a request fails
<error code>:
-
400 Invalid boolean aiMinCharLimit value, AI Min Char Limit must be a positive integer
-
401 unauthorized