All URIs are relative to http://portainer.domain/api
| Method | HTTP request | Description |
|---|---|---|
| stackCreate | POST /stacks | Deploy a new stack |
| stackDelete | DELETE /stacks/{id} | Remove a stack |
| stackFileInspect | GET /stacks/{id}/file | Retrieve the content of the Stack file for the specified stack |
| stackInspect | GET /stacks/{id} | Inspect a stack |
| stackList | GET /stacks | List stacks |
| stackMigrate | POST /stacks/{id}/migrate | Migrate a stack to another endpoint |
| stackUpdate | PUT /stacks/{id} | Update a stack |
Stack stackCreate(type, method, endpointId, opts)
Deploy a new stack
Deploy a new stack into a Docker environment specified via the endpoint identifier. Access policy: restricted
var PortainerApi = require('portainer_api');
var defaultClient = PortainerApi.ApiClient.instance;
// Configure API key authorization: jwt
var jwt = defaultClient.authentications['jwt'];
jwt.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//jwt.apiKeyPrefix = 'Token';
var apiInstance = new PortainerApi.StacksApi();
var type = 56; // Number | Stack deployment type. Possible values: 1 (Swarm stack) or 2 (Compose stack).
var method = "method_example"; // String | Stack deployment method. Possible values: file, string or repository.
var endpointId = 56; // Number | Identifier of the endpoint that will be used to deploy the stack.
var opts = {
'body': new PortainerApi.StackCreateRequest(), // StackCreateRequest | Stack details. Required when method equals string or repository.
'name': "name_example", // String | Name of the stack. Required when method equals file.
'endpointID': "endpointID_example", // String | Endpoint identifier used to deploy the stack. Required when method equals file.
'swarmID': "swarmID_example", // String | Swarm cluster identifier. Required when method equals file and type equals 1.
'file': "/path/to/file.txt", // File | Stack file. Required when method equals file.
'env': "env_example" // String | Environment variables passed during deployment, represented as a JSON array [{'name': 'name', 'value': 'value'}]. Optional, used when method equals file and type equals 1.
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.stackCreate(type, method, endpointId, opts, callback);
| Name | Type | Description | Notes |
|---|---|---|---|
| type | Number | Stack deployment type. Possible values: 1 (Swarm stack) or 2 (Compose stack). | |
| method | String | Stack deployment method. Possible values: file, string or repository. | |
| endpointId | Number | Identifier of the endpoint that will be used to deploy the stack. | |
| body | StackCreateRequest | Stack details. Required when method equals string or repository. | [optional] |
| name | String | Name of the stack. Required when method equals file. | [optional] |
| endpointID | String | Endpoint identifier used to deploy the stack. Required when method equals file. | [optional] |
| swarmID | String | Swarm cluster identifier. Required when method equals file and type equals 1. | [optional] |
| file | File | Stack file. Required when method equals file. | [optional] |
| env | String | Environment variables passed during deployment, represented as a JSON array [{'name': 'name', 'value': 'value'}]. Optional, used when method equals file and type equals 1. | [optional] |
stackDelete(id, opts)
Remove a stack
Remove a stack. Access policy: restricted
var PortainerApi = require('portainer_api');
var defaultClient = PortainerApi.ApiClient.instance;
// Configure API key authorization: jwt
var jwt = defaultClient.authentications['jwt'];
jwt.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//jwt.apiKeyPrefix = 'Token';
var apiInstance = new PortainerApi.StacksApi();
var id = 56; // Number | Stack identifier
var opts = {
'external': true, // Boolean | Set to true to delete an external stack. Only external Swarm stacks are supported.
'endpointId': "endpointId_example" // String | Endpoint identifier used to remove an external stack (required when external is set to true)
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully.');
}
};
apiInstance.stackDelete(id, opts, callback);
| Name | Type | Description | Notes |
|---|---|---|---|
| id | Number | Stack identifier | |
| external | Boolean | Set to true to delete an external stack. Only external Swarm stacks are supported. | [optional] |
| endpointId | String | Endpoint identifier used to remove an external stack (required when external is set to true) | [optional] |
null (empty response body)
StackFileInspectResponse stackFileInspect(id)
Retrieve the content of the Stack file for the specified stack
Get Stack file content. Access policy: restricted
var PortainerApi = require('portainer_api');
var defaultClient = PortainerApi.ApiClient.instance;
// Configure API key authorization: jwt
var jwt = defaultClient.authentications['jwt'];
jwt.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//jwt.apiKeyPrefix = 'Token';
var apiInstance = new PortainerApi.StacksApi();
var id = 56; // Number | Stack identifier
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.stackFileInspect(id, callback);
| Name | Type | Description | Notes |
|---|---|---|---|
| id | Number | Stack identifier |
Stack stackInspect(id)
Inspect a stack
Retrieve details about a stack. Access policy: restricted
var PortainerApi = require('portainer_api');
var defaultClient = PortainerApi.ApiClient.instance;
// Configure API key authorization: jwt
var jwt = defaultClient.authentications['jwt'];
jwt.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//jwt.apiKeyPrefix = 'Token';
var apiInstance = new PortainerApi.StacksApi();
var id = 56; // Number | Stack identifier
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.stackInspect(id, callback);
| Name | Type | Description | Notes |
|---|---|---|---|
| id | Number | Stack identifier |
StackListResponse stackList(opts)
List stacks
List all stacks based on the current user authorizations. Will return all stacks if using an administrator account otherwise it will only return the list of stacks the user have access to. Access policy: restricted
var PortainerApi = require('portainer_api');
var defaultClient = PortainerApi.ApiClient.instance;
// Configure API key authorization: jwt
var jwt = defaultClient.authentications['jwt'];
jwt.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//jwt.apiKeyPrefix = 'Token';
var apiInstance = new PortainerApi.StacksApi();
var opts = {
'filters': "filters_example" // String | Filters to process on the stack list. Encoded as JSON (a map[string]string). For example, {\"SwarmID\": \"jpofkc0i9uo9wtx1zesuk649w\"} will only return stacks that are part of the specified Swarm cluster. Available filters: EndpointID, SwarmID.
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.stackList(opts, callback);
| Name | Type | Description | Notes |
|---|---|---|---|
| filters | String | Filters to process on the stack list. Encoded as JSON (a map[string]string). For example, {"SwarmID": "jpofkc0i9uo9wtx1zesuk649w"} will only return stacks that are part of the specified Swarm cluster. Available filters: EndpointID, SwarmID. | [optional] |
Stack stackMigrate(id, opts)
Migrate a stack to another endpoint
Migrate a stack from an endpoint to another endpoint. It will re-create the stack inside the target endpoint before removing the original stack. Access policy: restricted
var PortainerApi = require('portainer_api');
var defaultClient = PortainerApi.ApiClient.instance;
// Configure API key authorization: jwt
var jwt = defaultClient.authentications['jwt'];
jwt.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//jwt.apiKeyPrefix = 'Token';
var apiInstance = new PortainerApi.StacksApi();
var id = 56; // Number | Stack identifier
var opts = {
'endpointId': 56, // Number | Stacks created before version 1.18.0 might not have an associated endpoint identifier. Use this optional parameter to set the endpoint identifier used by the stack.
'body': new PortainerApi.StackMigrateRequest() // StackMigrateRequest | Stack migration details.
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.stackMigrate(id, opts, callback);
| Name | Type | Description | Notes |
|---|---|---|---|
| id | Number | Stack identifier | |
| endpointId | Number | Stacks created before version 1.18.0 might not have an associated endpoint identifier. Use this optional parameter to set the endpoint identifier used by the stack. | [optional] |
| body | StackMigrateRequest | Stack migration details. | [optional] |
Stack stackUpdate(id, body, opts)
Update a stack
Update a stack. Access policy: restricted
var PortainerApi = require('portainer_api');
var defaultClient = PortainerApi.ApiClient.instance;
// Configure API key authorization: jwt
var jwt = defaultClient.authentications['jwt'];
jwt.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//jwt.apiKeyPrefix = 'Token';
var apiInstance = new PortainerApi.StacksApi();
var id = 56; // Number | Stack identifier
var body = new PortainerApi.StackUpdateRequest(); // StackUpdateRequest | Stack details
var opts = {
'endpointId': 56 // Number | Stacks created before version 1.18.0 might not have an associated endpoint identifier. Use this optional parameter to set the endpoint identifier used by the stack.
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.stackUpdate(id, body, opts, callback);
| Name | Type | Description | Notes |
|---|---|---|---|
| id | Number | Stack identifier | |
| body | StackUpdateRequest | Stack details | |
| endpointId | Number | Stacks created before version 1.18.0 might not have an associated endpoint identifier. Use this optional parameter to set the endpoint identifier used by the stack. | [optional] |