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