This adds the quotas api from /admin to /v2 with some changes. All users can GET /v2/quotas/<project_id> Users with "All-Projects" permission can view other projects (by setting X-Auth-All-Projects:True in the HTTP Headers) Users with "All-Projects" and "set-quotas" can set other projects quotas Moved the API rendering to Designate Object based rendering Change-Id: I7a0b828824ad6f274d922748f5f9a68157cd939a Depends-On: I06180a7402fc45940d4b312666cf2dfd33af1305changes/00/335100/8
parent
6395765b82
commit
619b4753cd
@ -0,0 +1,196 @@
|
||||
======
|
||||
Quotas
|
||||
======
|
||||
|
||||
Quota operations.
|
||||
|
||||
|
||||
View Quotas
|
||||
===========
|
||||
|
||||
.. rest_method:: GET /v2/quotas/{project_id}
|
||||
|
||||
View a projects quotas
|
||||
|
||||
This returns a key:value set of quotas on the system.
|
||||
|
||||
.. note::
|
||||
|
||||
If a user is viewing another projects quotas, they will need to set
|
||||
``x-auth-all-projects`` to ``True``
|
||||
|
||||
|
||||
They will need a role with the ``All-Projects`` permission to do this.
|
||||
|
||||
|
||||
Normal response codes: 200
|
||||
|
||||
Error response codes: 409,405,404,403,401,400,503
|
||||
|
||||
|
||||
Request
|
||||
-------
|
||||
|
||||
.. rest_parameters:: parameters.yaml
|
||||
|
||||
- x-auth-token: x-auth-token
|
||||
- x-auth-all-projects: x-auth-all-projects
|
||||
- x-auth-sudo-project-id: x-auth-sudo-project-id
|
||||
- project_id: path_project_id
|
||||
|
||||
|
||||
Response Parameters
|
||||
-------------------
|
||||
|
||||
.. rest_parameters:: parameters.yaml
|
||||
|
||||
- x-openstack-request-id: x-openstack-request-id
|
||||
|
||||
|
||||
Response Example
|
||||
----------------
|
||||
|
||||
.. literalinclude:: samples/quotas/get-quotas-response.json
|
||||
:language: javascript
|
||||
|
||||
|
||||
View Current Project's Quotas
|
||||
=============================
|
||||
|
||||
.. rest_method:: GET /v2/quotas/
|
||||
|
||||
View the quotas for the current project
|
||||
|
||||
This returns a key:value set of quotas on the system.
|
||||
|
||||
Normal response codes: 200
|
||||
|
||||
Error response codes: 409,405,404,403,401,400,503
|
||||
|
||||
|
||||
Request
|
||||
-------
|
||||
|
||||
.. rest_parameters:: parameters.yaml
|
||||
|
||||
- x-auth-token: x-auth-token
|
||||
- x-auth-all-projects: x-auth-all-projects
|
||||
- x-auth-sudo-project-id: x-auth-sudo-project-id
|
||||
- project_id: path_project_id
|
||||
|
||||
|
||||
Response Parameters
|
||||
-------------------
|
||||
|
||||
.. rest_parameters:: parameters.yaml
|
||||
|
||||
- x-openstack-request-id: x-openstack-request-id
|
||||
|
||||
|
||||
Response Example
|
||||
----------------
|
||||
|
||||
.. literalinclude:: samples/quotas/get-quotas-response.json
|
||||
:language: javascript
|
||||
|
||||
|
||||
Set Quotas
|
||||
==========
|
||||
|
||||
.. rest_method:: PATCH /v2/quotas/{project_id}
|
||||
|
||||
Set a projects quotas
|
||||
|
||||
The request should be a key:value set of quotas to be set
|
||||
|
||||
This returns a key:value set of quotas on the system.
|
||||
|
||||
.. note::
|
||||
|
||||
If a user is updating another projects quotas, they will need to set
|
||||
``x-auth-all-projects`` to ``True``
|
||||
|
||||
|
||||
They will need a role with the "All-Projects" and "set-quotas"
|
||||
permission to do this.
|
||||
|
||||
|
||||
Normal response codes: 200
|
||||
|
||||
Error response codes: 409,405,404,403,401,400,503
|
||||
|
||||
|
||||
Request Example
|
||||
---------------
|
||||
|
||||
.. literalinclude:: samples/quotas/set-quotas-request.json
|
||||
:language: javascript
|
||||
|
||||
Request
|
||||
-------
|
||||
|
||||
.. rest_parameters:: parameters.yaml
|
||||
|
||||
- x-auth-token: x-auth-token
|
||||
- x-auth-all-projects: x-auth-all-projects
|
||||
- x-auth-sudo-project-id: x-auth-sudo-project-id
|
||||
- project_id: path_project_id
|
||||
|
||||
|
||||
Response Parameters
|
||||
-------------------
|
||||
|
||||
.. rest_parameters:: parameters.yaml
|
||||
|
||||
- x-openstack-request-id: x-openstack-request-id
|
||||
|
||||
|
||||
Response Example
|
||||
----------------
|
||||
|
||||
.. literalinclude:: samples/quotas/set-quotas-response.json
|
||||
:language: javascript
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reset Quotas
|
||||
============
|
||||
|
||||
.. rest_method:: DELETE /v2/quotas/{project_id}
|
||||
|
||||
Reset all quotas for a project to default
|
||||
|
||||
.. note::
|
||||
|
||||
If a user is resetting another projects quotas, they will need to set
|
||||
``x-auth-all-projects`` to ``True``
|
||||
|
||||
They will need a role with the ``All-Projects`` and "set-quotas"
|
||||
permission to do this.
|
||||
|
||||
|
||||
Normal response codes: 204
|
||||
|
||||
Error response codes: 409,405,404,403,401,400,503
|
||||
|
||||
|
||||
Request
|
||||
-------
|
||||
|
||||
.. rest_parameters:: parameters.yaml
|
||||
|
||||
- x-auth-token: x-auth-token
|
||||
- x-auth-all-projects: x-auth-all-projects
|
||||
- x-auth-sudo-project-id: x-auth-sudo-project-id
|
||||
- project_id: path_project_id
|
||||
|
||||
|
||||
Response Parameters
|
||||
-------------------
|
||||
|
||||
.. rest_parameters:: parameters.yaml
|
||||
|
||||
- x-openstack-request-id: x-openstack-request-id
|
||||
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"api_export_size": 1000,
|
||||
"recordset_records": 20,
|
||||
"zone_records": 500,
|
||||
"zone_recordsets": 500,
|
||||
"zones": 100
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"zones": 500
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"api_export_size": 1000,
|
||||
"recordset_records": 20,
|
||||
"zone_records": 500,
|
||||
"zone_recordsets": 500,
|
||||
"zones": 500
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
# COPYRIGHT 2014 Rackspace
|
||||
#
|
||||
# Author: Tim Simmons <tim.simmons@rackspace.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import pecan
|
||||
from oslo_log import log as logging
|
||||
|
||||
from designate.api.v2.controllers import rest
|
||||
from designate.objects.adapters import DesignateAdapter
|
||||
from designate.objects import QuotaList
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class QuotasController(rest.RestController):
|
||||
|
||||
@pecan.expose(template='json:', content_type='application/json')
|
||||
def get_all(self):
|
||||
context = pecan.request.environ['context']
|
||||
|
||||
quotas = self.central_api.get_quotas(context, context.tenant)
|
||||
|
||||
quotas = QuotaList.from_dict(quotas)
|
||||
|
||||
return DesignateAdapter.render('API_v2', quotas)
|
||||
|
||||
@pecan.expose(template='json:', content_type='application/json')
|
||||
def get_one(self, tenant_id):
|
||||
context = pecan.request.environ['context']
|
||||
|
||||
quotas = self.central_api.get_quotas(context, tenant_id)
|
||||
|
||||
quotas = QuotaList.from_dict(quotas)
|
||||
|
||||
return DesignateAdapter.render('API_v2', quotas)
|
||||
|
||||
@pecan.expose(template='json:', content_type='application/json')
|
||||
def patch_one(self, tenant_id):
|
||||
"""Modify a Quota"""
|
||||
request = pecan.request
|
||||
context = request.environ['context']
|
||||
body = request.body_dict
|
||||
|
||||
quotas = DesignateAdapter.parse('API_v2', body, QuotaList())
|
||||
|
||||
for quota in quotas:
|
||||
self.central_api.set_quota(context, tenant_id, quota.resource,
|
||||
quota.hard_limit)
|
||||
|
||||
quotas = self.central_api.get_quotas(context, tenant_id)
|
||||
|
||||
quotas = QuotaList.from_dict(quotas)
|
||||
|
||||
return DesignateAdapter.render('API_v2', quotas)
|
||||
|
||||
@pecan.expose(template=None, content_type='application/json')
|
||||
def delete_one(self, tenant_id):
|
||||
"""Reset to the Default Quotas"""
|
||||
request = pecan.request
|
||||
response = pecan.response
|
||||
context = request.environ['context']
|
||||
|
||||
self.central_api.reset_quotas(context, tenant_id)
|
||||
|
||||
response.status_int = 204
|
||||
|
||||
return ''
|
@ -0,0 +1,15 @@
|
||||
---
|
||||
features:
|
||||
- This adds the quotas api from /admin to /v2 with some changes.
|
||||
|
||||
All users can GET /v2/quotas/<project_id>
|
||||
|
||||
Users with "All-Projects" permission can view other projects
|
||||
(by setting X-Auth-All-Projects:True in the HTTP Headers)
|
||||
|
||||
Users with "All-Projects" and "set-quotas" can set other
|
||||
projects quotas
|
||||
|
||||
Moved the API rendering to Designate Object based rendering
|
||||
fixes:
|
||||
- V1 API Users can now query v1/quotas/<project_id> for quotas
|
Loading…
Reference in new issue