Ejemplo n.º 1
0
from jsonschema import exceptions as jsonschema_exc
import six

from nova.api.openstack import api_version_request as api_version
from nova.api import validation
from nova.api.validation import parameter_types
from nova.api.validation import validators
from nova import exception
from nova import test
from nova.tests.unit.api.openstack import fakes


query_schema = {
    'type': 'object',
    'properties': {
        'foo': parameter_types.single_param({'type': 'string',
                                             'format': 'uuid'}),
        'foos': parameter_types.multi_params({'type': 'string'})
    },
    'patternProperties': {
        "^_": parameter_types.multi_params({'type': 'string'})},
    'additionalProperties': True
}


class FakeQueryParametersController(object):

    @validation.query_schema(query_schema, '2.3')
    def get(self, req):
        return list(set(req.GET.keys()))

Ejemplo n.º 2
0
from jsonschema import exceptions as jsonschema_exc
import six

from nova.api.openstack import api_version_request as api_version
from nova.api import validation
from nova.api.validation import parameter_types
from nova.api.validation import validators
from nova import exception
from nova import test
from nova.tests.unit.api.openstack import fakes

query_schema = {
    'type': 'object',
    'properties': {
        'foo': parameter_types.single_param({
            'type': 'string',
            'format': 'uuid'
        }),
        'foos': parameter_types.multi_params({'type': 'string'})
    },
    'patternProperties': {
        "^_": parameter_types.multi_params({'type': 'string'})
    },
    'additionalProperties': True
}


class FakeQueryParametersController(object):
    @validation.query_schema(query_schema, '2.3')
    def get(self, req):
        return list(set(req.GET.keys()))
Ejemplo n.º 3
0
list_query_schema_v233 = {
    'type': 'object',
    'properties': parameter_types.pagination_parameters,
    # NOTE(gmann): This is kept True to keep backward compatibility.
    # As of now Schema validation stripped out the additional parameters and
    # does not raise 400. In microversion 2.53, the additional parameters
    # are not allowed.
    'additionalProperties': True
}

list_query_schema_v253 = {
    'type': 'object',
    'properties': {
        # The 2.33 microversion added support for paging by limit and marker.
        'limit': parameter_types.single_param(
            parameter_types.non_negative_integer),
        'marker': parameter_types.single_param({'type': 'string'}),
        # The 2.53 microversion adds support for filtering by hostname pattern
        # and requesting hosted servers in the GET /os-hypervisors and
        # GET /os-hypervisors/detail response.
        'hypervisor_hostname_pattern': parameter_types.single_param(
            parameter_types.hostname),
        'with_servers': parameter_types.single_param(
            parameter_types.boolean)
    },
    'additionalProperties': False
}

show_query_schema_v253 = {
    'type': 'object',
    'properties': {
Ejemplo n.º 4
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 copy

from nova.api.validation import parameter_types

list_query_params_v258 = {
    'type': 'object',
    'properties': {
        # The 2.58 microversion added support for paging by limit and marker
        # and filtering by changes-since.
        'limit': parameter_types.single_param(
            parameter_types.non_negative_integer),
        'marker': parameter_types.single_param({'type': 'string'}),
        'changes-since': parameter_types.single_param(
            {'type': 'string', 'format': 'date-time'}),
    },
    'additionalProperties': False
}

list_query_params_v266 = copy.deepcopy(list_query_params_v258)
list_query_params_v266['properties'].update({
    'changes-before': parameter_types.single_param(
            {'type': 'string', 'format': 'date-time'}),
})
Ejemplo n.º 5
0
list_query_schema_v233 = {
    'type': 'object',
    'properties': parameter_types.pagination_parameters,
    # NOTE(gmann): This is kept True to keep backward compatibility.
    # As of now Schema validation stripped out the additional parameters and
    # does not raise 400. In microversion 2.53, the additional parameters
    # are not allowed.
    'additionalProperties': True
}

list_query_schema_v253 = {
    'type': 'object',
    'properties': {
        # The 2.33 microversion added support for paging by limit and marker.
        'limit':
        parameter_types.single_param(parameter_types.non_negative_integer),
        'marker':
        parameter_types.single_param({'type': 'string'}),
        # The 2.53 microversion adds support for filtering by hostname pattern
        # and requesting hosted servers in the GET /os-hypervisors and
        # GET /os-hypervisors/detail response.
        'hypervisor_hostname_pattern':
        parameter_types.single_param(parameter_types.fqdn),
        'with_servers':
        parameter_types.single_param(parameter_types.boolean)
    },
    'additionalProperties': False
}

show_query_schema_v253 = {
    'type': 'object',
Ejemplo n.º 6
0
# 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.

from nova.api.validation import parameter_types

list_query_params_v258 = {
    'type': 'object',
    'properties': {
        # The 2.58 microversion added support for paging by limit and marker
        # and filtering by changes-since.
        'limit':
        parameter_types.single_param(parameter_types.non_negative_integer),
        'marker':
        parameter_types.single_param({'type': 'string'}),
        'changes-since':
        parameter_types.single_param({
            'type': 'string',
            'format': 'date-time'
        }),
    },
    'additionalProperties': False
}
Ejemplo n.º 7
0
    'type': 'object',
    'properties': {
        'hidden': parameter_types.common_query_param,
        'host': parameter_types.common_query_param,
        'instance_uuid': parameter_types.common_query_param,
        'source_compute': parameter_types.common_query_param,
        'status': parameter_types.common_query_param,
        'migration_type': parameter_types.common_query_param,
    },
    # For backward compatible changes
    'additionalProperties': True
}

list_query_params_v259 = copy.deepcopy(list_query_schema_v20)
list_query_params_v259['properties'].update({
    # The 2.59 microversion added support for paging by limit and marker
    # and filtering by changes-since.
    'limit': parameter_types.single_param(
        parameter_types.non_negative_integer),
    'marker': parameter_types.single_param({'type': 'string'}),
    'changes-since': parameter_types.single_param(
        {'type': 'string', 'format': 'date-time'}),
})
list_query_params_v259['additionalProperties'] = False

list_query_params_v266 = copy.deepcopy(list_query_params_v259)
list_query_params_v266['properties'].update({
    'changes-before': parameter_types.single_param(
        {'type': 'string', 'format': 'date-time'}),
})