mirror of
https://github.com/portainer/portainer.git
synced 2025-08-05 13:55:21 +02:00
refactor(stacks): break swagger docs by type [EE-5381] (#8820)
This commit is contained in:
parent
bbea0bc8a5
commit
77f8b9333a
33 changed files with 347 additions and 144 deletions
|
@ -5,7 +5,7 @@ function EdgeJobsFactory($resource, API_ENDPOINT_EDGE_JOBS) {
|
|||
API_ENDPOINT_EDGE_JOBS + '/:id/:action',
|
||||
{},
|
||||
{
|
||||
create: { method: 'POST' },
|
||||
create: { method: 'POST', params: { id: 'create', action: '@method' } },
|
||||
query: { method: 'GET', isArray: true },
|
||||
get: { method: 'GET', params: { id: '@id' } },
|
||||
update: { method: 'PUT', params: { id: '@id' } },
|
||||
|
|
|
@ -5,7 +5,7 @@ angular.module('portainer.edge').factory('EdgeStacks', function EdgeStacksFactor
|
|||
API_ENDPOINT_EDGE_STACKS + '/:id/:action',
|
||||
{},
|
||||
{
|
||||
create: { method: 'POST', ignoreLoadingBar: true },
|
||||
create: { method: 'POST', ignoreLoadingBar: true, params: { id: 'create', action: '@method' } },
|
||||
query: { method: 'GET', isArray: true },
|
||||
get: { method: 'GET', params: { id: '@id' } },
|
||||
update: { method: 'PUT', params: { id: '@id' } },
|
||||
|
|
|
@ -49,7 +49,7 @@ function EdgeJobService(EdgeJobs, EdgeJobResults, FileUploadService) {
|
|||
|
||||
service.createEdgeJobFromFileContent = function (model) {
|
||||
var payload = new ScheduleCreateRequest(model);
|
||||
return EdgeJobs.create({ method: 'string' }, payload).$promise;
|
||||
return EdgeJobs.create({}, { method: 'string', ...payload }).$promise;
|
||||
};
|
||||
|
||||
service.createEdgeJobFromFileUpload = function (model) {
|
||||
|
|
|
@ -30,7 +30,7 @@ angular.module('portainer.edge').factory('EdgeStackService', function EdgeStackS
|
|||
|
||||
service.createStackFromFileContent = async function createStackFromFileContent(payload) {
|
||||
try {
|
||||
return await EdgeStacks.create({ method: 'string' }, payload).$promise;
|
||||
return await EdgeStacks.create({}, { method: 'string', ...payload }).$promise;
|
||||
} catch (err) {
|
||||
throw { msg: 'Unable to create the stack', err };
|
||||
}
|
||||
|
@ -47,9 +47,10 @@ angular.module('portainer.edge').factory('EdgeStackService', function EdgeStackS
|
|||
service.createStackFromGitRepository = async function createStackFromGitRepository(payload, repositoryOptions) {
|
||||
try {
|
||||
return await EdgeStacks.create(
|
||||
{ method: 'repository' },
|
||||
{},
|
||||
{
|
||||
...payload,
|
||||
method: 'repository',
|
||||
RepositoryURL: repositoryOptions.RepositoryURL,
|
||||
RepositoryReferenceName: repositoryOptions.RepositoryReferenceName,
|
||||
FilePathInRepository: repositoryOptions.FilePathInRepository,
|
||||
|
|
|
@ -7,7 +7,7 @@ function CustomTemplatesFactory($resource, API_ENDPOINT_CUSTOM_TEMPLATES) {
|
|||
API_ENDPOINT_CUSTOM_TEMPLATES + '/:id/:action',
|
||||
{},
|
||||
{
|
||||
create: { method: 'POST', ignoreLoadingBar: true },
|
||||
create: { method: 'POST', ignoreLoadingBar: true, params: { id: 'create', action: '@method' } },
|
||||
query: { method: 'GET', isArray: true },
|
||||
get: { method: 'GET', params: { id: '@id' } },
|
||||
update: { method: 'PUT', params: { id: '@id' } },
|
||||
|
|
|
@ -10,7 +10,7 @@ function StackFactory($resource, API_ENDPOINT_STACKS) {
|
|||
{
|
||||
get: { method: 'GET', params: { id: '@id' } },
|
||||
query: { method: 'GET', isArray: true },
|
||||
create: { method: 'POST', ignoreLoadingBar: true },
|
||||
create: { method: 'POST', ignoreLoadingBar: true, params: { id: 'create', subaction: '@method', action: '@type' } },
|
||||
update: { method: 'PUT', params: { id: '@id' }, ignoreLoadingBar: true },
|
||||
associate: { method: 'PUT', params: { id: '@id', swarmId: '@swarmId', endpointId: '@endpointId', orphanedRunning: '@orphanedRunning', action: 'associate' } },
|
||||
remove: { method: 'DELETE', params: { id: '@id', external: '@external', endpointId: '@endpointId' } },
|
||||
|
|
|
@ -40,7 +40,7 @@ function CustomTemplateServiceFactory($sanitize, CustomTemplates, FileUploadServ
|
|||
|
||||
service.createCustomTemplateFromFileContent = async function createCustomTemplateFromFileContent(payload) {
|
||||
try {
|
||||
return await CustomTemplates.create({ method: 'string' }, payload).$promise;
|
||||
return await CustomTemplates.create({}, { method: 'string', ...payload }).$promise;
|
||||
} catch (err) {
|
||||
throw { msg: 'Unable to create the customTemplate', err };
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ function CustomTemplateServiceFactory($sanitize, CustomTemplates, FileUploadServ
|
|||
|
||||
service.createCustomTemplateFromGitRepository = async function createCustomTemplateFromGitRepository(payload) {
|
||||
try {
|
||||
return await CustomTemplates.create({ method: 'repository' }, payload).$promise;
|
||||
return await CustomTemplates.create({}, { method: 'repository', ...payload }).$promise;
|
||||
} catch (err) {
|
||||
throw { msg: 'Unable to create the customTemplate', err };
|
||||
}
|
||||
|
|
|
@ -317,7 +317,7 @@ angular.module('portainer.app').factory('StackService', [
|
|||
StackFileContent: stackFileContent,
|
||||
Env: env,
|
||||
};
|
||||
return Stack.create({ method: 'string', type: 2, endpointId: endpointId }, payload).$promise;
|
||||
return Stack.create({ endpointId: endpointId }, { method: 'string', type: 'standalone', ...payload }).$promise;
|
||||
};
|
||||
|
||||
service.createSwarmStackFromFileContent = function (name, stackFileContent, env, endpointId) {
|
||||
|
@ -331,7 +331,7 @@ angular.module('portainer.app').factory('StackService', [
|
|||
StackFileContent: stackFileContent,
|
||||
Env: env,
|
||||
};
|
||||
return Stack.create({ method: 'string', type: 1, endpointId: endpointId }, payload).$promise;
|
||||
return Stack.create({ endpointId: endpointId }, { method: 'string', type: 'swarm', ...payload }).$promise;
|
||||
})
|
||||
.then(function success(data) {
|
||||
deferred.resolve(data);
|
||||
|
@ -362,7 +362,7 @@ angular.module('portainer.app').factory('StackService', [
|
|||
payload.AutoUpdate = repositoryOptions.AutoUpdate;
|
||||
}
|
||||
|
||||
return Stack.create({ method: 'repository', type: 2, endpointId: endpointId }, payload).$promise;
|
||||
return Stack.create({ endpointId: endpointId }, { method: 'repository', type: 'standalone', ...payload }).$promise;
|
||||
};
|
||||
|
||||
service.createSwarmStackFromGitRepository = function (name, repositoryOptions, env, endpointId) {
|
||||
|
@ -390,7 +390,7 @@ angular.module('portainer.app').factory('StackService', [
|
|||
payload.AutoUpdate = repositoryOptions.AutoUpdate;
|
||||
}
|
||||
|
||||
return Stack.create({ method: 'repository', type: 1, endpointId: endpointId }, payload).$promise;
|
||||
return Stack.create({ endpointId: endpointId }, { method: 'repository', type: 'swarm', ...payload }).$promise;
|
||||
})
|
||||
.then(function success(data) {
|
||||
deferred.resolve(data);
|
||||
|
@ -409,7 +409,7 @@ angular.module('portainer.app').factory('StackService', [
|
|||
|
||||
async function kubernetesDeployAsync(endpointId, method, payload) {
|
||||
try {
|
||||
await Stack.create({ endpointId: endpointId, method: method, type: 3 }, payload).$promise;
|
||||
await Stack.create({ endpointId: endpointId }, { method, type: 'kubernetes', ...payload }).$promise;
|
||||
} catch (err) {
|
||||
throw { err: err };
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ angular.module('portainer.app').factory('FileUploadService', [
|
|||
|
||||
service.createSchedule = function (payload) {
|
||||
return Upload.upload({
|
||||
url: 'api/edge_jobs?method=file',
|
||||
url: 'api/edge_jobs/create/file',
|
||||
data: {
|
||||
file: payload.File,
|
||||
Name: payload.Name,
|
||||
|
@ -90,7 +90,7 @@ angular.module('portainer.app').factory('FileUploadService', [
|
|||
|
||||
service.createSwarmStack = function (stackName, swarmId, file, env, endpointId) {
|
||||
return Upload.upload({
|
||||
url: 'api/stacks?method=file&type=1&endpointId=' + endpointId,
|
||||
url: `api/stacks/create/swarm/file?endpointId=${endpointId}`,
|
||||
data: {
|
||||
file: file,
|
||||
Name: stackName,
|
||||
|
@ -103,7 +103,7 @@ angular.module('portainer.app').factory('FileUploadService', [
|
|||
|
||||
service.createComposeStack = function (stackName, file, env, endpointId) {
|
||||
return Upload.upload({
|
||||
url: 'api/stacks?method=file&type=2&endpointId=' + endpointId,
|
||||
url: `api/stacks/create/standalone/file?endpointId=${endpointId}`,
|
||||
data: {
|
||||
file: file,
|
||||
Name: stackName,
|
||||
|
@ -115,7 +115,7 @@ angular.module('portainer.app').factory('FileUploadService', [
|
|||
|
||||
service.createEdgeStack = function createEdgeStack({ EdgeGroups, ...payload }, file) {
|
||||
return Upload.upload({
|
||||
url: 'api/edge_stacks?method=file',
|
||||
url: `api/edge_stacks/create/file`,
|
||||
data: {
|
||||
file,
|
||||
EdgeGroups: Upload.json(EdgeGroups),
|
||||
|
@ -127,7 +127,7 @@ angular.module('portainer.app').factory('FileUploadService', [
|
|||
|
||||
service.createCustomTemplate = function createCustomTemplate(data) {
|
||||
return Upload.upload({
|
||||
url: 'api/custom_templates?method=file',
|
||||
url: 'api/custom_templates/create/file',
|
||||
data,
|
||||
ignoreLoadingBar: true,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue