mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-01 01:18:10 +02:00
Update OpenAPI feature strategies (#4175)
## About the changes Updates for endpoint `/api/admin/projects/{projectId}/features/{featureName}/environments/{environment}/strategies` and similar
This commit is contained in:
parent
6f15eb9f4c
commit
ace499d7c6
@ -123,7 +123,6 @@ const metaRules: Rule[] = [
|
||||
'tagWithVersionSchema',
|
||||
'uiConfigSchema',
|
||||
'updateFeatureSchema',
|
||||
'updateFeatureStrategySchema',
|
||||
'updateTagTypeSchema',
|
||||
'upsertContextFieldSchema',
|
||||
'upsertStrategySchema',
|
||||
@ -151,7 +150,6 @@ const metaRules: Rule[] = [
|
||||
'batchStaleSchema',
|
||||
'cloneFeatureSchema',
|
||||
'createFeatureSchema',
|
||||
'createFeatureStrategySchema',
|
||||
'createInvitedUserSchema',
|
||||
'dateSchema',
|
||||
'environmentsSchema',
|
||||
@ -183,7 +181,6 @@ const metaRules: Rule[] = [
|
||||
'tagWithVersionSchema',
|
||||
'uiConfigSchema',
|
||||
'updateFeatureSchema',
|
||||
'updateFeatureStrategySchema',
|
||||
'updateTagTypeSchema',
|
||||
'upsertContextFieldSchema',
|
||||
'upsertStrategySchema',
|
||||
|
@ -6,10 +6,11 @@ export const createFeatureStrategySchema = {
|
||||
$id: '#/components/schemas/createFeatureStrategySchema',
|
||||
type: 'object',
|
||||
required: ['name'],
|
||||
description: 'Create a strategy configuration in a feature',
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string',
|
||||
description: 'The name or type of strategy',
|
||||
description: 'The name of the strategy type',
|
||||
example: 'flexibleRollout',
|
||||
},
|
||||
title: {
|
||||
@ -32,7 +33,8 @@ export const createFeatureStrategySchema = {
|
||||
},
|
||||
constraints: {
|
||||
type: 'array',
|
||||
description: 'A list of the constraints attached to the strategy',
|
||||
description:
|
||||
'A list of the constraints attached to the strategy. See https://docs.getunleash.io/reference/strategy-constraints',
|
||||
example: [
|
||||
{
|
||||
values: ['1', '2'],
|
||||
|
@ -53,7 +53,8 @@ export const featureStrategySchema = {
|
||||
},
|
||||
constraints: {
|
||||
type: 'array',
|
||||
description: 'A list of the constraints attached to the strategy',
|
||||
description:
|
||||
'A list of the constraints attached to the strategy. See https://docs.getunleash.io/reference/strategy-constraints',
|
||||
items: {
|
||||
$ref: '#/components/schemas/constraintSchema',
|
||||
},
|
||||
|
@ -5,18 +5,24 @@ import { constraintSchema } from './constraint-schema';
|
||||
export const updateFeatureStrategySchema = {
|
||||
$id: '#/components/schemas/updateFeatureStrategySchema',
|
||||
type: 'object',
|
||||
description: 'Update a strategy configuration in a feature',
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string',
|
||||
description: 'The name of the strategy type',
|
||||
},
|
||||
sortOrder: {
|
||||
type: 'number',
|
||||
description:
|
||||
'The order of the strategy in the list in feature environment configuration',
|
||||
},
|
||||
constraints: {
|
||||
type: 'array',
|
||||
items: {
|
||||
$ref: '#/components/schemas/constraintSchema',
|
||||
},
|
||||
description:
|
||||
'A list of the constraints attached to the strategy. See https://docs.getunleash.io/reference/strategy-constraints',
|
||||
},
|
||||
title: {
|
||||
type: 'string',
|
||||
|
@ -261,9 +261,13 @@ export default class ProjectFeaturesController extends Controller {
|
||||
middleware: [
|
||||
openApiService.validPath({
|
||||
tags: ['Features'],
|
||||
summary: 'Get feature toggle strategies.',
|
||||
operationId: 'getFeatureStrategies',
|
||||
description:
|
||||
'Get strategies defined for a feature toggle in the specified environment.',
|
||||
responses: {
|
||||
200: createResponseSchema('featureStrategySchema'),
|
||||
...getStandardResponses(401, 403, 404),
|
||||
},
|
||||
}),
|
||||
],
|
||||
@ -277,12 +281,16 @@ export default class ProjectFeaturesController extends Controller {
|
||||
middleware: [
|
||||
openApiService.validPath({
|
||||
tags: ['Features'],
|
||||
summary: 'Add a strategy to a feature toggle.',
|
||||
description:
|
||||
'Add a strategy to a feature toggle in the specified environment.',
|
||||
operationId: 'addFeatureStrategy',
|
||||
requestBody: createRequestSchema(
|
||||
'createFeatureStrategySchema',
|
||||
),
|
||||
responses: {
|
||||
200: createResponseSchema('featureStrategySchema'),
|
||||
...getStandardResponses(401, 403, 404),
|
||||
},
|
||||
}),
|
||||
],
|
||||
@ -296,6 +304,9 @@ export default class ProjectFeaturesController extends Controller {
|
||||
middleware: [
|
||||
openApiService.validPath({
|
||||
tags: ['Features'],
|
||||
summary: 'Get a strategy configuration.',
|
||||
description:
|
||||
'Get a strategy configuration for an environment in a feature toggle.',
|
||||
operationId: 'getFeatureStrategy',
|
||||
responses: {
|
||||
200: createResponseSchema('featureStrategySchema'),
|
||||
@ -312,12 +323,14 @@ export default class ProjectFeaturesController extends Controller {
|
||||
middleware: [
|
||||
openApiService.validPath({
|
||||
tags: ['Features'],
|
||||
summary: 'Set the order of strategies on the list.',
|
||||
operationId: 'setStrategySortOrder',
|
||||
requestBody: createRequestSchema(
|
||||
'setStrategySortOrderSchema',
|
||||
),
|
||||
responses: {
|
||||
200: emptyResponse,
|
||||
...getStandardResponses(401, 403),
|
||||
},
|
||||
}),
|
||||
],
|
||||
@ -331,6 +344,9 @@ export default class ProjectFeaturesController extends Controller {
|
||||
middleware: [
|
||||
openApiService.validPath({
|
||||
tags: ['Features'],
|
||||
summary: 'Update a strategy.',
|
||||
description:
|
||||
'Replace strategy configuration for a feature toggle in the specified environment.',
|
||||
operationId: 'updateFeatureStrategy',
|
||||
requestBody: createRequestSchema(
|
||||
'updateFeatureStrategySchema',
|
||||
@ -350,6 +366,9 @@ export default class ProjectFeaturesController extends Controller {
|
||||
middleware: [
|
||||
openApiService.validPath({
|
||||
tags: ['Features'],
|
||||
summary: 'Change specific properties of a strategy.',
|
||||
description:
|
||||
'Change specific properties of a strategy configuration in a feature toggle.',
|
||||
operationId: 'patchFeatureStrategy',
|
||||
requestBody: createRequestSchema('patchesSchema'),
|
||||
responses: {
|
||||
@ -367,9 +386,15 @@ export default class ProjectFeaturesController extends Controller {
|
||||
permission: DELETE_FEATURE_STRATEGY,
|
||||
middleware: [
|
||||
openApiService.validPath({
|
||||
operationId: 'deleteFeatureStrategy',
|
||||
tags: ['Features'],
|
||||
responses: { 200: emptyResponse },
|
||||
summary: 'Delete a strategy from a feature toggle.',
|
||||
description:
|
||||
'Delete a strategy configuration from a feature toggle in the specified environment.',
|
||||
operationId: 'deleteFeatureStrategy',
|
||||
responses: {
|
||||
200: emptyResponse,
|
||||
...getStandardResponses(401, 403, 404),
|
||||
},
|
||||
}),
|
||||
],
|
||||
});
|
||||
@ -798,7 +823,7 @@ export default class ProjectFeaturesController extends Controller {
|
||||
const { features } = req.body;
|
||||
|
||||
if (this.flagResolver.isEnabled('disableBulkToggle')) {
|
||||
res.status(409).end();
|
||||
res.status(403).end();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -830,7 +855,7 @@ export default class ProjectFeaturesController extends Controller {
|
||||
const { features } = req.body;
|
||||
|
||||
if (this.flagResolver.isEnabled('disableBulkToggle')) {
|
||||
res.status(409).end();
|
||||
res.status(403).end();
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user