fix(retention) add delete retention API (#14747)

Signed-off-by: Ziming Zhang <zziming@vmware.com>
This commit is contained in:
Ziming 2021-05-14 14:15:42 +08:00 committed by GitHub
parent 35c9a98272
commit 1665dbcbc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 1 deletions

View File

@ -4137,6 +4137,8 @@ paths:
operationId: getRentenitionMetadata
tags:
- Retention
parameters:
- $ref: '#/parameters/requestId'
responses:
'200':
description: Get Retention Metadatas successfully.
@ -4154,6 +4156,7 @@ paths:
tags:
- Retention
parameters:
- $ref: '#/parameters/requestId'
- name: policy
in: body
description: Create Retention Policy successfully.
@ -4180,6 +4183,7 @@ paths:
tags:
- Retention
parameters:
- $ref: '#/parameters/requestId'
- name: id
in: path
type: integer
@ -4207,6 +4211,7 @@ paths:
tags:
- Retention
parameters:
- $ref: '#/parameters/requestId'
- name: id
in: path
type: integer
@ -4227,6 +4232,32 @@ paths:
$ref: '#/responses/403'
'500':
$ref: '#/responses/500'
delete:
summary: Delete Retention Policy
operationId: deleteRetention
description: >-
Delete Retention Policy, you can reference metadatas API for the policy model.
You can check project metadatas to find whether a retention policy is already binded.
This method should only be called when retention policy has already binded to project.
tags:
- Retention
parameters:
- $ref: '#/parameters/requestId'
- name: id
in: path
type: integer
format: int64
required: true
description: Retention ID.
responses:
'200':
description: Update Retention Policy successfully.
'401':
$ref: '#/responses/401'
'403':
$ref: '#/responses/403'
'500':
$ref: '#/responses/500'
/retentions/{id}/executions:
post:
@ -4238,6 +4269,7 @@ paths:
produces:
- text/plain
parameters:
- $ref: '#/parameters/requestId'
- name: id
in: path
type: integer
@ -4270,6 +4302,7 @@ paths:
tags:
- Retention
parameters:
- $ref: '#/parameters/requestId'
- name: id
in: path
type: integer
@ -4318,6 +4351,7 @@ paths:
tags:
- Retention
parameters:
- $ref: '#/parameters/requestId'
- name: id
in: path
type: integer
@ -4357,6 +4391,7 @@ paths:
tags:
- Retention
parameters:
- $ref: '#/parameters/requestId'
- name: id
in: path
type: integer
@ -4413,6 +4448,7 @@ paths:
produces:
- text/plain
parameters:
- $ref: '#/parameters/requestId'
- name: id
in: path
type: integer

View File

@ -227,10 +227,26 @@ func (r *retentionAPI) checkRuleConflict(p *policy.Metadata) error {
return nil
}
func (r *retentionAPI) DeleteRetention(ctx context.Context, params operation.DeleteRetentionParams) middleware.Responder {
p, err := r.retentionCtl.GetRetention(ctx, params.ID)
if err != nil {
return r.SendError(ctx, errors.BadRequestError(err))
}
err = r.requireAccess(ctx, p, rbac.ActionDelete)
if err != nil {
return r.SendError(ctx, err)
}
if err = r.retentionCtl.DeleteRetention(ctx, params.ID); err != nil {
return r.SendError(ctx, err)
}
return operation.NewDeleteRetentionOK()
}
func (r *retentionAPI) TriggerRetentionExecution(ctx context.Context, params operation.TriggerRetentionExecutionParams) middleware.Responder {
p, err := r.retentionCtl.GetRetention(ctx, params.ID)
if err != nil {
return r.SendError(ctx, errors.BadRequestError((err)))
return r.SendError(ctx, errors.BadRequestError(err))
}
err = r.requireAccess(ctx, p, rbac.ActionUpdate)
if err != nil {