yakumo.keystone.v2.endpoint

Package yakumo :: Package keystone :: Package v2 :: Module endpoint |
[hide private]
[frames] | no frames]

# Source Code for Module yakumo.keystone.v2.endpoint

     1  # Copyright 2014-2017 by Akira Yoshiyama <akirayoshiyama@gmail.com>.
     2  # All Rights Reserved.
     3  #
     4  #    Licensed under the Apache License, Version 2.0 (the "License"); you may
     5  #    not use this file except in compliance with the License. You may obtain
     6  #    a copy of the License at
     7  #
     8  #         http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  #    Unless required by applicable law or agreed to in writing, software
    11  #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    12  #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    13  #    License for the specific language governing permissions and limitations
    14  #    under the License.
    15
    16  """
    17  Resource class and its manager for endpoints in Identity V2 API
    18  """
    19
    20  from yakumo import base
    21  from yakumo.constant import UNDEF
    22  from yakumo import mapper
    23  from yakumo import exception
    24
    25
    26  ATTRIBUTE_MAPPING = [
    27      ('id', 'id', mapper.Noop),
    28      ('public_url', 'publicurl', mapper.Noop),
    29      ('internal_url', 'internalurl', mapper.Noop),
    30      ('admin_url', 'adminurl', mapper.Noop),
    31      ('region', 'region', mapper.Noop),
    32      ('is_enabled', 'enabled', mapper.Noop),
    33      ('service', 'service_id', mapper.Resource('keystone.service')),
    34  ]
    35
    36
    37 -class Resource(base.Resource):
    38      """resource class for endpoints on Identity V2 API"""
    39
    40
    41 -class Manager(base.Manager):
    42      """manager class for endpoints on Identity V2 API"""
    43
    44      resource_class = Resource
    45      service_type = 'identity'
    46      _attr_mapping = ATTRIBUTE_MAPPING
    47      _hidden_methods = ["update"]
    48      _json_resource_key = 'endpoint'
    49      _json_resources_key = 'endpoints'
    50      _url_resource_path = '/endpoints'
    51
    52 -    def create(self, public_url=UNDEF, internal_url=UNDEF, admin_url=UNDEF,
    53                 region=UNDEF, is_enabled=UNDEF, service=UNDEF):
    54          """
    55          Register endpoints for a service
    56
    57          @keyword public_url: URL of the public endpoint
    58          @type public_url: str
    59          @keyword internal_url: URL of the internal endpoint
    60          @type internal_url: str
    61          @keyword admin_url: URL of the admin endpoint
    62          @type admin_url: str
    63          @keyword region: Region name
    64          @type region: str
    65          @keyword is_enabled: Whether the endpoints are enabled or not
    66          @type is_enabled: bool
    67          @keyword service: Service
    68          @type service: yakumo.keystone.v2.service.Resource
    69          @return: Created endpoint
    70          @rtype: yakumo.keystone.v2.endpoint.Resource
    71          """
    72          return super(Manager, self).create(
    73              public_url=public_url,
    74              internal_url=internal_url,
    75              admin_url=admin_url,
    76              region=region,
    77              is_enabled=is_enabled,
    78              service=service)
    79
    80 -    def get(self, id):
    81          try:
    82              ret = self.find_one(id=id)
    83              if ret is None:
    84                  raise exception.NotFound
    85              return ret
    86          except exception.Forbidden:
    87              return self.get_empty(id)
    88