"Fossies" - the Fresh Open Source Software Archive

Member "solum-12.0.0/solum/api/controllers/camp/v1_1/formats.py" (30 Mar 2022, 2405 Bytes) of package /linux/misc/openstack/solum-12.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "formats.py" see the Fossies "Dox" file reference documentation.

    1 #
    2 # Licensed under the Apache License, Version 2.0 (the "License"); you may
    3 # not use this file except in compliance with the License. You may obtain
    4 # a copy of the License at
    5 #
    6 #      http://www.apache.org/licenses/LICENSE-2.0
    7 #
    8 # Unless required by applicable law or agreed to in writing, software
    9 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   10 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   11 # License for the specific language governing permissions and limitations
   12 # under the License.
   13 
   14 import pecan
   15 from pecan import core
   16 from pecan import rest
   17 from wsme import types as wtypes
   18 import wsmeext.pecan as wsme_pecan
   19 
   20 from solum.api.controllers.camp.v1_1.datamodel import format
   21 from solum.api.controllers.camp.v1_1.datamodel import formats
   22 from solum.api.controllers.camp.v1_1 import uris
   23 from solum.api.controllers import common_types
   24 from solum.api.handlers.camp import format_handler
   25 from solum.common import exception
   26 
   27 
   28 DESCRIPTION_STRING = "Solum CAMP API supported formats collection resource."
   29 
   30 
   31 class FormatsController(rest.RestController):
   32     """Manages operations on CAMP's formats resource."""
   33 
   34     @exception.wrap_wsme_controller_exception
   35     @wsme_pecan.wsexpose(format.Format, wtypes.text)
   36     def get_one(self, format_name):
   37         """Return the appropriate format resource."""
   38         handler = (format_handler.
   39                    FormatHandler(pecan.request.security_context))
   40         raw_format = handler.get(format_name)
   41         if not raw_format:
   42             core.abort(404,
   43                        '%s is not a format resource' %
   44                        format_name)
   45         host_url = pecan.request.application_url.rstrip('/')
   46         return raw_format.fix_uris(host_url)
   47 
   48     @exception.wrap_wsme_controller_exception
   49     @wsme_pecan.wsexpose(formats.Formats)
   50     def get(self):
   51         """Return the formats resource."""
   52         host_url = pecan.request.application_url.rstrip('/')
   53         links = [common_types.Link(href=uris.JSON_FORMAT_URI_STR % host_url,
   54                                    target_name=uris.JSON_FORMAT_NAME_STR)]
   55         return formats.Formats(uri=uris.FORMATS_URI_STR % host_url,
   56                                name='Solum_CAMP_formats',
   57                                type='formats',
   58                                description=DESCRIPTION_STRING,
   59                                format_links=links)