Update the api doc part of scheduled operation

The api doc is not consistent with the codes regarding to scheduled
operation, so update it.

Change-Id: I4f1d9d2f64d6d02d4015ea54124ee170029ba525
This commit is contained in:
zengchen 2016-09-05 16:13:58 +08:00
parent bbc3c673a9
commit 5ea596efb1
3 changed files with 133 additions and 73 deletions

View File

@ -267,45 +267,55 @@ None
> **get** : /v1/{project_id}/scheduled_operations > **get** : /v1/{project_id}/scheduled_operations
#### Response JSON #### #### Response JSON ####
```json ```json
[ {"operations": [
{ {"scheduled_operation": {
"id": "1a2c0c3d-f402-4cd8-b5db-82e85cb51fad", "id": "1a2c0c3d-f402-4cd8-b5db-82e85cb51fad",
"name": "My scheduled operation", "name": "My scheduled operation",
"project_id": "23902b02-5666-4ee6-8dfe-962ac09c3994", "description": "It will run everyday",
"operation_type": "protect", "operation_type": "protect",
"operation_definition": { "trigger_id": "23902b02-5666-4ee6-8dfe-962ac09c3995",
"trigger_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398", "operation_definition": {
"plan_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398" "provider_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa399",
} "plan_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398"
}, },
] "enabled": 1
}
},
],
"operations_links": ""
}
``` ```
### Create Scheduled Operation ### ### Create Scheduled Operation ###
> **post** : /v1/{project_id}/scheduled_operations > **post** : /v1/{project_id}/scheduled_operations
#### Request JSON #### #### Request JSON ####
```json ```json
{ {"scheduled_operation": {
"name": "My scheduled operation", "name": "My scheduled operation",
"project_id": "23902b02-5666-4ee6-8dfe-962ac09c3994", "description": "It will run everyday",
"operation_type": "protect", "operation_type": "protect",
"operation_definition": { "trigger_id": "23902b02-5666-4ee6-8dfe-962ac09c3995",
"trigger_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398", "operation_definition": {
"plan_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398" "provider_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa399",
"plan_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398"
}
} }
} }
``` ```
#### Response JSON #### #### Response JSON ####
```json ```json
{ {"scheduled_operation": {
"id": "1a2c0c3d-f402-4cd8-b5db-82e85cb51fad", "id": "1a2c0c3d-f402-4cd8-b5db-82e85cb51fad",
"name": "My scheduled operation", "name": "My scheduled operation",
"project_id": "23902b02-5666-4ee6-8dfe-962ac09c3994", "description": "It will run everyday",
"operation_type": "protect", "operation_type": "protect",
"operation_definition": { "trigger_id": "23902b02-5666-4ee6-8dfe-962ac09c3995",
"trigger_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398", "operation_definition": {
"plan_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398" "provider_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa399",
"plan_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398"
},
"enabled": 1
} }
} }
``` ```
@ -314,16 +324,18 @@ None
> **get** : /v1/{project_id}/scheduled_operations/{scheduled_operation_id} > **get** : /v1/{project_id}/scheduled_operations/{scheduled_operation_id}
#### Response JSON #### #### Response JSON ####
```json ```json
{ {"scheduled_operation": {
"id": "1a2c0c3d-f402-4cd8-b5db-82e85cb51fad", "id": "1a2c0c3d-f402-4cd8-b5db-82e85cb51fad",
"name": "My scheduled operation", "name": "My scheduled operation",
"project_id": "23902b02-5666-4ee6-8dfe-962ac09c3994", "description": "It will run everyday",
"operation_type": "protect", "operation_type": "protect",
"operation_definition": { "trigger_id": "23902b02-5666-4ee6-8dfe-962ac09c3995",
"trigger_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398", "operation_definition": {
"plan_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398" "provider_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa399",
}, "plan_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398"
"next_schedule_time": "2016-1-5T08:30:00" },
"enabled": 1
}
} }
``` ```

View File

@ -613,6 +613,9 @@ paths:
parameters: parameters:
- $ref: '#/parameters/projectParam' - $ref: '#/parameters/projectParam'
- $ref: '#/parameters/nameFilterParam' - $ref: '#/parameters/nameFilterParam'
- $ref: '#/parameters/scheduled_operation_typeFilterParam'
- $ref: '#/parameters/trigger_idParam'
- $ref: '#/parameters/scheduled_operation_defFilterParam'
- $ref: '#/parameters/sortParam' - $ref: '#/parameters/sortParam'
- $ref: '#/parameters/limitParam' - $ref: '#/parameters/limitParam'
- $ref: '#/parameters/markerParam' - $ref: '#/parameters/markerParam'
@ -627,18 +630,24 @@ paths:
items: items:
$ref: '#/definitions/ScheduledOperation' $ref: '#/definitions/ScheduledOperation'
examples: examples:
application/json: [ application/json: {
{ "operations": [ {
"id": "1a2c0c3d-f402-4cd8-b5db-82e85cb51fad", "scheduled_operation": {
"name": "My scheduled operation", "id": "1a2c0c3d-f402-4cd8-b5db-82e85cb51fad",
"project_id": "23902b02-5666-4ee6-8dfe-962ac09c3994", "name": "My scheduled operation",
"operation_type": "protect", "description": "It will run everyday",
"trigger_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398", "operation_type": "protect",
"operation_definition": { "trigger_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398",
"plan_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398" "operation_definition": {
} "provider_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa399",
}, "plan_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398"
] },
"enabled": 1
}
},
],
"operations_links": ""
}
default: default:
description: Unexpected error description: Unexpected error
schema: schema:
@ -656,7 +665,7 @@ paths:
in: body in: body
required: true required: true
schema: schema:
$ref: '#/definitions/ScheduledOperation' $ref: '#/definitions/ScheduledOperationCreateBody'
responses: responses:
'200': '200':
description: The new scheduled operation description: The new scheduled operation
@ -664,15 +673,19 @@ paths:
$ref: '#/definitions/ScheduledOperation' $ref: '#/definitions/ScheduledOperation'
examples: examples:
application/json: { application/json: {
"id": "1a2c0c3d-f402-4cd8-b5db-82e85cb51fad", "scheduled_operation": {
"name": "My scheduled operation", "id": "1a2c0c3d-f402-4cd8-b5db-82e85cb51fad",
"project_id": "23902b02-5666-4ee6-8dfe-962ac09c3994", "name": "My scheduled operation",
"operation_type": "protect", "description": "It will run everyday",
"trigger_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398", "operation_type": "protect",
"operation_definition": { "trigger_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398",
"plan_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398" "operation_definition": {
"provider_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa399",
"plan_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398",
},
"enabled": 1
}
} }
}
default: default:
description: Unexpected error description: Unexpected error
schema: schema:
@ -695,15 +708,19 @@ paths:
$ref: '#/definitions/ScheduledOperation' $ref: '#/definitions/ScheduledOperation'
examples: examples:
application/json: { application/json: {
"id": "1a2c0c3d-f402-4cd8-b5db-82e85cb51fad", "scheduled_operation": {
"name": "My scheduled operation", "id": "1a2c0c3d-f402-4cd8-b5db-82e85cb51fad",
"project_id": "23902b02-5666-4ee6-8dfe-962ac09c3994", "name": "My scheduled operation",
"operation_type": "protect", "description": "It will run everyday",
"trigger_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398", "operation_type": "protect",
"operation_definition": { "trigger_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398",
"plan_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398" "operation_definition": {
"provider_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa399",
"plan_id": "2a9ce1f3-cc1a-4516-9435-0ebb13caa398"
},
"enabled": 1
}
} }
}
default: default:
description: Unexpected error description: Unexpected error
schema: schema:
@ -1316,19 +1333,38 @@ definitions:
name: name:
type: string type: string
description: Display name of scheduled operation. description: Display name of scheduled operation.
project_id:
type: string
format: UUID
operation_type:
type: string
description: description:
type: string type: string
description: Description about the scheduled operation. description: Description about the scheduled operation.
operation_type:
type: string
trigger_id: trigger_id:
type: string type: string
format: UUID format: UUID
operation_definition: operation_definition:
$ref: '#/definitions/OperationDefinition' type: object
description: |
Supply parameters for the operation type.
enabled:
type: integer
ScheduledOperationCreateBody:
type: object
properties:
name:
type: string
description: Display name of scheduled operation.
description:
type: string
description: Description about the scheduled operation.
operation_type:
type: string
trigger_id:
type: string
format: UUID
operation_definition:
type: object
description: |
Supply parameters for the operation type.
OperationStatus: OperationStatus:
type: object type: object
properties: properties:
@ -1587,6 +1623,19 @@ parameters:
required: true required: true
in: path in: path
description: id of the scheduled operation. description: id of the scheduled operation.
scheduled_operation_typeFilterParam:
name: operation_type
in: query
description: type of the scheduled operation.
required: false
type: string
scheduled_operation_defFilterParam:
name: operation_definition
in: query
format: regex
description: definition of the scheduled operation. Could be a regex pattern.
required: false
type: string
operation_log_idParam: operation_log_idParam:
name: operation_log_id name: operation_log_id
type: string type: string

View File

@ -50,7 +50,6 @@ class ScheduledOperationViewBuilder(common.ViewBuilder):
'name': operation.get('name'), 'name': operation.get('name'),
'description': operation.get('description'), 'description': operation.get('description'),
'operation_type': operation.get('operation_type'), 'operation_type': operation.get('operation_type'),
'project_id': operation.get('project_id'),
'trigger_id': operation.get('trigger_id'), 'trigger_id': operation.get('trigger_id'),
'operation_definition': operation.get('operation_definition'), 'operation_definition': operation.get('operation_definition'),
'enabled': operation.get('enabled'), 'enabled': operation.get('enabled'),