Add quotas resource operation in API doc

Change-Id: I2108f2c6bf067ce228829de9c4e7e47005acf358
This commit is contained in:
Lingxian Kong 2019-12-11 00:07:11 +13:00
parent 0907c8ec61
commit f16020392d
6 changed files with 151 additions and 2 deletions

View File

@ -15,3 +15,4 @@
.. include:: datastores.inc
.. include:: configurations.inc
.. include:: backups.inc
.. include:: quotas.inc

View File

@ -60,6 +60,12 @@ user_name:
in: path
required: false
type: string
user_project:
description: |
The project ID of the user's project.
in: path
required: true
type: string
# variables in body
access:
description: |
@ -608,6 +614,42 @@ nics:
in: body
required: false
type: array
quota_in_use:
description: |
The used quota for a resource.
in: body
required: true
type: integer
quota_limit:
description: |
The limit of a resource quota.
in: body
required: true
type: integer
quota_list:
description: |
A list of resource quotas.
in: body
required: true
type: array
quota_reserved:
description: |
The reserved quota for a resource.
in: body
required: true
type: integer
quota_resource:
description: |
The resource name.
in: body
required: true
type: string
quotas:
description: |
Dictionary that defines the resources quota.
in: body
required: true
type: string
region_name:
description: |
The region name of an instance.

80
api-ref/source/quotas.inc Normal file
View File

@ -0,0 +1,80 @@
.. -*- rst -*-
======
Quotas
======
Show and update quotas.
Show resources quota for a specific project
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. rest_method:: GET /v1.0/{project_id}/mgmt/quotas/{user_project}
Admin only action by default.
Normal response codes: 200
Request
-------
.. rest_parameters:: parameters.yaml
- project_id: project_id
- user_project: user_project
Response Parameters
-------------------
.. rest_parameters:: parameters.yaml
- quotas: quota_list
- resource: quota_resource
- in_use: quota_in_use
- limit: quota_limit
- reserved: quota_reserved
Response Example
----------------
.. literalinclude:: samples/quota-show-response.json
:language: javascript
Update resources quota for a specific project
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. rest_method:: PUT /v1.0/{project_id}/mgmt/quotas/{user_project}
Admin only action by default.
Normal response codes: 200
Request
-------
.. rest_parameters:: parameters.yaml
- project_id: project_id
- user_project: user_project
- quotas: quotas
Request Example
---------------
.. literalinclude:: samples/quota-update.json
:language: javascript
Response Parameters
-------------------
.. rest_parameters:: parameters.yaml
- quotas: quotas
Response Example
----------------
.. literalinclude:: samples/quota-update.json
:language: javascript

View File

@ -0,0 +1,22 @@
{
"quotas": [
{
"in_use": 5,
"limit": 15,
"reserved": 0,
"resource": "instances"
},
{
"in_use": 2,
"limit": 50,
"reserved": 0,
"resource": "backups"
},
{
"in_use": 1,
"limit": 40,
"reserved": 0,
"resource": "volumes"
}
]
}

View File

@ -0,0 +1,5 @@
{
"quotas": {
"instances": 20
}
}

View File

@ -349,8 +349,7 @@ QUOTAS = QuotaEngine()
''' Define all kind of resources here '''
resources = [Resource(Resource.INSTANCES,
'max_instances_per_tenant'),
resources = [Resource(Resource.INSTANCES, 'max_instances_per_tenant'),
Resource(Resource.BACKUPS, 'max_backups_per_tenant'),
Resource(Resource.VOLUMES, 'max_volumes_per_tenant')]